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

int main() {
    string s;
    cin >> s;
    string::iterator it = s.end();
    long long ans=0;
    long long  cnt = 1;
    while (*(--it)!='x') {
        char c = *(it);
        if(isdigit(c)){
            ans = ans+ (c-'0')*cnt;
        }else{
            ans += (10+c-'A')*cnt;
        }

        cnt *= 16;
        
    }
    cout << ans << endl;
    return 0;
}
// 64 位输出请用 printf("%lld")