#include
using namespace std;
int main() {
long long a;
cin >> a;
if(a == 1) {
cout << 1 << endl;
}
else {
long long poceten_broj = (a - 2) / 4 * 20;
poceten_broj += 2;
long long desetka = (a / 10) % 10;
long long cifra = a % 10;
if(desetka % 2 == 1) {
if(cifra == 0 or cifra == 4 or cifra == 8) {
cout << poceten_broj << endl;
}
else if(cifra == 1 or cifra == 5 or cifra == 9) {
cout << poceten_broj + 2 << endl;
}
else if(cifra == 2 or cifra == 6) {
cout << poceten_broj + 6 << endl;
}
else {
cout << poceten_broj + 14 << endl;
}
}
else {
if(cifra == 0 or cifra == 4 or cifra == 8) {
cout << poceten_broj + 6 << endl;
}
else if(cifra == 1 or cifra == 5 or cifra == 9) {
cout << poceten_broj + 14 << endl;
}
else if(cifra == 2 or cifra == 6) {
cout << poceten_broj << endl;
}
else {
cout << poceten_broj + 2 << endl;
}
}
}
return 0;
}
// 1, 2, 4, 8, 16, 22, 24, 28, 36, 42, 44, 48, 56
// 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
// 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 44, 48, 52