#include <stdio.h>
#include <string.h>
int f(char arr []){
int sum=0;
for(int i=0;i<strlen(arr);i++){
if(arr[i]>='0'&&arr[i]<='9'){
arr[i]=arr[i]-'0';
}
else if(arr[i]>='a'&&arr[i]<='f'){
arr[i]=arr[i]-'a'+10;
}
else if(arr[i]>='A'&&arr[i]<='F'){
arr[i]=arr[i]-'A'+10;
}
sum=sum*16+arr[i];
}
printf("%d\n",sum);
}
int main(){
char a[3];
scanf("%s",a);
f(a);
return 0;
}