#include<stdio.h>
int main(){
char s[50];
scanf("%s",s);
int t,i;
long sum=0;
for(i=0;s[i];i++){
if(s[i]<='9')
t=s[i]-'0';
else
t=s[i]-'A'+10;
sum=sum*16+t;
}
printf("%ld\n",sum);
return 0;
}