#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
while (cin >> str)
{
int tag = 0;
if (str[0] == '-') tag++;
str = str.substr(2 + tag);
int res = 0;
for (int i = 0; i < str.size(); i++)
{
int x;
if (str[i] <= '9') x = str[i] - '0';
else if (str[i] <= 'Z') x = str[i] - 'A' + 10;
else x = str[i] - 'a' + 10;
res = res * 16 + x;
}
if (tag) cout << "-";
cout << res << endl;
}
return 0;
}