#include<iostream>
using namespace std;
int main(){
int bottle =0;
int a=0 , b=0;
int sum=0;
while(cin >> bottle && bottle !=0){
int sum=0;
while(bottle>1){
a = bottle/3;
b = bottle%3;
sum += a;
bottle = a+b;
if((a+b)==2){
sum+=1;
bottle=0;
}
}
cout << sum << endl;
}
}