#include<stdio.h>
int main(){
char ch;
int flag=0,sgn=1;
long sum=0;
ch=getchar();
while(ch!='#'){
if(ch=='-'&&flag==0) sgn=-1;
else if(ch>='0'&&ch<='9') {
sum=sum*16+ch-'0';
flag=1;
}
else if(ch>='a'&&ch<='f') {
sum=sum*16+ch-'a'+10;
flag=1;
}
else if(ch>='A'&&ch<='F') {
sum=sum*16+ch-'A'+10;
flag=1;
}
ch=getchar();
}
printf("%d",sum*sgn);
return 0;
}