#include <iostream>
using namespace std;
int main() {
int bow;
while(cin>>bow){
if(bow==0)break;
int count=0;
while(bow>2){
count+=bow/3;
bow=bow/3+bow%3;
}
if(bow==2)count++;
cout<<count<<endl;
}
}
// 64 位输出请用 printf("%lld")

京公网安备 11010502036488号