#include <iostream>
using namespace std;

int main() {
    while (true) {
        int X, ans = 0;

        // Entrada do valor de X
        cout << "Digite X (0 para sair): ";
        cin >> X;

        if (X == 0) {
            break;
        }

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

        cout << ans << endl;
    }

    return 0;
}
