#include <bits/stdc++.h>
using namespace std;
int main(){
int i;
int count;
while(cin>>i){
if(i==0) return 0;
count=0;
while(i>=2){
if(i>=3){
count+=i/3;
i=i%3+i/3;
}else{
count++;
i=0;
}
}
cout<<count<<endl;
}
return 0;
}