j = input()

i = int(j,16)
if i >=1 and i <= ((2**31)-1): 
    print(i)