咱就用这个笨方法吧。


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String input = scanner.nextLine();
            if (input == null) {
                break;
            }
            int num = Integer.parseInt(input);
            int res = drinkNum(num);
            System.out.println(res == 0 ? "" : res);
        }
        scanner.close();
    }

    public static int drinkNum(int bottle) {
        int res = bottle / 3;


        int resTemp = res;
        int last = bottle % 3 + resTemp;


        while (last >= 2) {
            if (last == 2) {
                res += 1;
                break;
            }
            resTemp = last / 3;
            res += resTemp;
            last = last % 3 + resTemp;
        }
        return res;
    }
}