#include <iostream>
using namespace std;
int CharToInt(char c){
    if(c >= '0' && c <= '9')    return c - '0';
    else return c - 'A' + 10;
}
int main() {
    string str;
    while (cin >> str) {
        int x = 0;
        for(int i = 2; i < str.length(); i ++){
            x = x * 16 + CharToInt(str[i]);
        }
        cout << x << endl;
    }
    return 0;
}