import java.util.Scanner;

public class Arvore {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            // Entrada do valor de X
            System.out.print("Digite X (0 para sair): ");
            int X = scanner.nextInt();
            
            if (X == 0) {
                break;
            }

            int ans = 0;

            if (X < 6) {
                switch (X) {
                    case 1:
                        ans = 1;
                        break;
                    case 2:
                        ans = 2;
                        break;
                    case 3:
                        ans = 4;
                        break;
                    case 4:
                        ans = 5;
                        break;
                    case 5:
                        ans = 7;
                        break;
                }
            } else {
                ans = 13;
                while (X > 6) {
                    ans += 6;
                    X--;
                }
            }

            System.out.println(ans);
        }

        scanner.close();
    }
}
