N, B = map(int, input().split())
res = []
while(N):
    val = N%B
    if val>9:
        res.append(chr(val+ord('A')-10))
    else:
        res.append(chr(val+ord('0')))
    N//=B
print(''.join(res[::-1]))