#include<iostream> using namespace std; int main() { int n; while(cin>>n) { if(n==0) return 0; int ans=0; ans+=n/3; n=n%3; n+=ans; while(n>=3) { int s=n/3; ans+=s; n=n%3; n+=s; } cout<<ans<<endl; } return 0; }