str="0123456789ABCDEF" def f(x,m): if x//m: f(x//m,m) print(str[x%m],end='') x=int(input()) m=int(input()) f(x,m)