#include <iostream>
#include <string>
#include <cmath>

int main(int argc, char* argv[]){
    std::string str;
    std::cin >> str;
    int res = 0;
    int i = 0;
    int j = str.size() - 1;
    while(str[j] != 'x'){
        int num;
        if(str[j] >= '0' && str[j] <= '9'){
            num = str[j] - '0';
        }
        else {
            num = str[j] - 55;
        }
        res += pow(16, i) * num;
        --j;
        ++i;
    }
    std::cout << res <<std::endl;
    return 0;
}