intmain() { int n; for (; cin >> n; ) { if (!n) break; int res = 0; for (; n > 2;) { int bottle = n / 3; res += bottle; n %= 3; n += bottle; } cout << (n == 2 ? res + 1 : res) << endl; } return0; }
publicclassMain{ publicstaticvoidmain(String[] args){ Scanner in = new Scanner(System.in); for (; in.hasNext();) { int n = in.nextInt(); if (n == 0) break; int res = 0; for (; n > 2;) { int bottle = n / 3; n %= 3; n += bottle; res += bottle; } if (n == 2) System.out.println(res + 1); else System.out.println(res); } } }