문제: https://www.acmicpc.net/problem/2745
import sys
read = lambda : sys.stdin.readline().strip()
n, b = read().split(' ')
ans = 0
for i in n:
ans *= int(b)
if i < 'A':
ans += int(i)
else:
ans += int(ord(i))-55
print(ans)