开心

import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        while(scan.hasNext()){
            int n = scan.nextInt();
            int count = 0;
            if(n == 0) break;
            while(n>=3){
                count += n/3;
                n = n/3+n%3;
            }
            if(n == 2){
                count++;
            }
            System.out.println(count);
        }
    }
}