import java.util.Scanner;

public class Main {

    private int cal(int number) {
        int bottoms = 0;
        while (number >= 3) {
            bottoms += number/3;
            number = number%3 + number/3;
        }
        if (number == 2) {
            bottoms++;
        }
        return bottoms;
    }
    public Main() {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int number = in.nextInt();
            if (number == 0) break;
            int result = cal(number);
            System.out.println(result);
        }
    }

    public static void main(String[] args) {
        Main solution = new Main();
    }
}