#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#define maxn 1000
using namespace std;

int StoI(char c) {
    int num;
    if (c >= '0' && c <= '9') {
        num = c - '0';
    } else if (c >= 'A' && c <= 'Z') {
        num =  10 + c - 'A';
    } else if (c >= 'a' && c <= 'z') {
        num =  10 + c - 'a';
    }
    return num;
}




string mul(string s1, string s2) {
    int len1 = s1.size(), len2 = s2.size();
    if (len1 < len2)swap(s1, s2);

    int len = len1 + len2 + 2;
    int cur[len];
    memset(cur, 0, sizeof(cur));
    string str = "";
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());
    for (int i = 0; i < s1.size(); i++) {
        for (int j = 0; j < s2.size(); j++) {
            int n1 = StoI(s1[i]), n2 = StoI(s2[j]);
            cur[i + j] += n1 * n2;
        }
    }
    for (int i = 0; i < len; i++) {
        int car = cur[i] / 10;
        cur[i] %= 10;
        cur[i + 1] += car;
        char c = '0' + cur[i];
        str = str + c;
    }
    reverse(str.begin(), str.end());
    while (str[0] == '0')str.erase(0, 1);
    if (str == "")str = "0";
    return str;

}

// string ItoS(int x)
// {
//     string str="";
//     while(x!=0)
//     {
//         char c = '0' + (x%10);
//         str = str +c;
//         x/=10;
//     }
//     reverse(str.begin(),str.end());
//      while(str[0]=='0')str.erase(0,1);
//     if(str=="")str="0";
//     return str;

// }
string Add(string s, int x) { //加法
    reverse(s.begin(), s.end());
    int carry = x;
    for (int i = 0; i < s.size(); i++) {
        int cur = s[i] - '0' + carry;
        s[i] = cur % 10 + '0';
        carry = cur / 10;
    }
    if (carry != 0) {
        s = "1" + s;
    }
    reverse(s.begin(), s.end());
    return s;
}

string add(string s1, char c) {
    int x = StoI(c);
    // string str = "";
    int car = x;
//   cout<<"s2 = "<<s2<<endl;
    reverse(s1.begin(), s1.end());
    for (int i = 0; i < s1.size(); i++) {

        int num = (s1[i] - '0') + car;
//       cout<<"num = "<<num<<endl;
        s1[i] = num % 10 + '0';
        car = num / 10;
        // str = str + c;
    }
//   if(car==1)s1 = s1 + "1";
    if (car != 0) {
        s1 =  s1 + "1";
    }
//   cout<<"car = "<<car<<endl;

    reverse(s1.begin(), s1.end());
    while (s1[0] == '0')s1.erase(0, 1);
    if (s1 == "")s1 = "0";
    return s1;

}

int main() {
    string s;
    while (cin >> s) {
        //     cin >> s;
        s = s.substr(2);
        int pos = s.size();
        string answ = "0";
        for (int i = 0; i < pos; i++) {
            answ = mul(answ, "16");
            // cout << "mul  :" << answ << endl;
            answ = add(answ, s[i]);
            //  cout << "s[i]= " << s[i] << endl;
            //  cout << "add = " << answ << endl;
        }
        // answ = "171";
        // answ = mul(answ,"16");

        cout << answ << endl;
    }



}
// 64 位输出请用 printf("%lld")