import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); // 目标橙子数量 // 标签用于找到结果后直接结束 res: { // 全用8个装的情况 if (n % 8 == 0) { System.out.println(n / 8); break res; } // 从多到少尝试8个装的袋数 for (int e = n / 8; e >= 0; e--) { int left = n - e * 8; // 剩余橙子数 // 剩余数量能被6整除 if (left >= 0 && left % 6 == 0) { System.out.println(e + left / 6); // 总袋数 break res; } } // 无法恰好购买 System.out.println(-1); } sc.close(); } }