#include<iostream>
#include<cstring>
using namespace std;
int main() {
char s[260];
long long int s, x = 1, nr;
cin >> s;
for (int i = strlen(s) - 1; i >= 0; i--) {
if (s[i] >= '0' && s[i] <= '9')
nr = s[i] - '0';
else
nr = s[i] - 'A' + 10;
s += x * nr;
x = x * 16;
}
cout << s;
return 0;
}