#include <bits/stdc++.h> using namespace std; int main(){ string s; while(cin>>s) { double res=0; for(int i=s.length()-1;i>=2;i--) { if(s[i]>='A'&&s[i]<='Z') { res+=(s[i]-'A'+10)*pow(16,s.length()-1-i); } else res+=(s[i]-'0')*pow(16,s.length()-1-i); } cout<<res<<endl; } return 0; }