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