#include <iostream>
#include <string>
using namespace std;
int main() {
string a;
int b;
cin >> a >> b;
if (a == "ShunZhi"){
cout << 1643 + b;
}
else if (a == "KangXi"){
cout << 1661 + b;
}
else if (a == "YongZheng"){
cout << 1722 + b;
}
else if (a == "QianLong"){
cout << 1735 + b;
}
else if (a == "JiaQing"){
cout << 1795 + b;
}
else if (a == "DaoGuang"){
cout << 1820 + b;
}
else if (a == "XianFeng"){
cout << 1850 + b;
}
else if (a == "TongZhi"){
cout << 1861 + b;
}
else if (a == "GuangXu"){
cout << 1874 + b;
}
else if (a == "XuanTong"){
cout << 1908 + b;
}
return 0;
}