#include <iostream>
using namespace std;

int main() {
    string str;
    while(cin>>str){
        int res=0;
        for(int i=2;i<str.size();i++){
            if(str[i]>='0'&&str[i]<='9')res=16*res+str[i]-'0';
            else res=16*res+str[i]-'A'+10;
        }
        cout<<res<<endl;
    }
}