#include<stdio.h>
int main()
{
    int n=0, huan=0;
    while(scanf("%d", &n)!=EOF)
    {
        int  cnt=0;
        if(n==0)
            break;
        while(n>1)
        {
            huan = n / 3;
            cnt += huan;
            n = n % 3 + huan;
            if(n==2)
            {
                cnt += 1;
                break;
            }
        }
        printf("%d\n", cnt);
    }
    return 0;
}