#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
while(cin>>s){
long long ans=0;
for(int i=2;i<s.size();i++){
int x;
if(s[i]>='a'&&s[i]<='f')x=s[i]-'a'+10;
else if(s[i]>='A'&&s[i]<='F')x=s[i]-'A'+10;
else x=s[i]-'0';
ans=ans*16+x;
}
printf("%lld\n",ans);
}
return 0;
}