#include <iostream> // 模拟 递归! using namespace std; int calc(int n){ if(n < 2) return 0; if(n == 2) return 1; int ret = 0; int has = n / 3; int dot = n % 3; ret += has; n = has + dot; // 剩余的瓶子! return ret + calc(n); } int main(){ int n; while(cin >> n){ if(n == 0) break; cout << calc(n) << endl; } return 0; }