#include <iostream>
using namespace std;
int function(int x)
{
    int num=0;
    while(x>2)
    {
        num = num + x/3;
        x = (x/3)+(x%3);
    }
    if(x==2)
    {
        return num+1;
    }
    else
    {
        return num;
    }
}
int main()
{
    int num;
    while(cin>>num)
    {
        if(num)
        {
            cout<<function(num)<<endl;
        }
    }
}