#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() 
{
    char num[20] = {0};

    scanf("%s",num);
    
    long result = 0;
    int value = 0;
    int length = strlen(num);

    for(int i = 2;i < length;i ++)
    {
        char ch = toupper(num[i]);
        if(ch >= '0'&&ch <='9')
        {
            value  = ch - '0';
        }
        else if(ch >= 'A'&& ch <='F')
        {
            value  = ch - 'A' + 10;
        }
        result = result *16 + value;
    }

    printf("%ld",result);

    return 0;
}