#include<stdio.h>
#define N 50
int fun(char s[])
{
int i,t;
int sum =0;
for(i=0;s[i];i++)
{
if(s[i]>='0'&&s[i]<='9')
t=s[i]-'0';
if(s[i]>='a'&&s[i]<='f')
t=s[i]-'a'+10;
if(s[i]>='A'&&s[i]<='F')
t=s[i]-'A'+10;
sum=sum*16+t;
}
return sum;
}
int main()
{
int m;
char a[N];
scanf("%s",a);
m=fun(a);
printf("%d",m);
}