#include<stdio.h>
int main(){
int i=0,j,flag=0,n=0;
char ch,a[80];
a[0]='\0';
while((ch=getchar())!='#'){
if(ch=='-'&&a[0]=='\0'){
a[i]=ch;
i++;
}
if((ch>='a'&&ch<='f')||(ch>='A'&&ch<='F')||(ch>='0'&&ch<='9')){
a[i]=ch;
i++;
flag=1;
}
}
if(a[0]=='-'&&flag)printf("-");
j=i;
for(i=0;i<j;i++){
if(a[i]>='0'&&a[i]<='9')n=n*16+a[i]-'0';
else if(a[i]>='A'&&a[i]<='Z')n=n*16+a[i]-'A'+10;
else if(a[i]>='a'&&a[i]<='z')n=n*16+a[i]-'a'+10;
}
printf("%d",n);
return 0;
}