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