import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        
        while(sc.hasNextInt()){
            int n=sc.nextInt();
            if(n==0) break;
            
            int res=0;
            int k;
            
            while(n>1){
                k=n/3;
                res+=k;
                n=n%3+k;
                
                if(n==2){
                    res+=1;
                    break;
                }
            }
            System.out.println(res);
        }
    }
}