#include <iostream> #include <string> #include <cmath> using namespace std; long long Dec; int main() { string Hex; int HexLength; while(cin >> Hex) { HexLength = Hex.length(); Dec = 0; for(int i = HexLength - 1; i >= 0; --i){ if(Hex[i] >= '0' && Hex[i] <= '9') Dec += pow(16, HexLength - 1 - i) * (Hex[i] - '0'); else if(Hex[i] >= 'A' && Hex[i] <= 'F') Dec += pow(16, HexLength - 1 - i) * (Hex[i] - 'A' + 10); } cout << Dec << endl; } }