#一行题解#

print(sum(int(x, 16) if "0x" in x else int(x, 8) for x in input().split()))