#include <stdio.h>
#include <stdint.h>
uint16_t hex_to_uint(const char *str) {
uint16_t val = 0;
while (*str != '\0'){
int digit;
if ( *str >= '0' && *str <= '9'){
digit = *str - '0';
}
else if ((*str >= 'A' && *str <= 'F')){
digit = *str - 'A' + 10;
}
else if ((*str >= 'a' && *str <= 'f')){
digit = *str - 'a' + 10;
}
str++;
val = (val << 4) | digit;
}
// Your logic here
return val;
}
int main() {
char hex[10];
scanf("%s", hex);
printf("%u", hex_to_uint(hex));
return 0;
}