#include<bits/stdc++.h> using namespace std; char s[1000], *stop; int main(){ while(cin >> s){ printf("%d\n", strtol(s, &stop, 16)); } return 0; }