#include<bits/stdc++.h>
using namespace std;
string str;
int main()
{
char x;
while((x=getchar())!=EOF)
{
getline(cin,str);
int num=0;bool flag=false;
if(x=='-')flag=true;
else
{
if(x>='0'&&x<='9')
num+=x-'0';
else if(x>='a'&&x<='f')
num+=x-'a'+10;
else num+=x-'A'+10;
}
for(int i=0;i<str.length();i++)
{
num*=16;
if(str[i]>='0'&&str[i]<='9')
num+=str[i]-'0';
else if(str[i]>='a'&&str[i]<='f')
num+=str[i]-'a'+10;
else num+=str[i]-'A'+10;
}
if(flag)num=-num;
printf("%d\n",num);
// str.~string();//?????????
}
return 0;
}