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