#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main(){
    string number;
    while(getline(cin,number)){
        int resultant=0;
        int index;
        for(int i=2;i<number.size();++i){
           resultant=number[i]<='9'?(resultant*16+number[i]-'0'):(resultant*16+number[i]-'A'+10);
        }
        printf("%d\n",resultant);
    }
    return 0;
}