n = int(input()) p = int(input()) ans = [] while n: n, m = divmod(n, p) ans.append(m) print(*ans[::-1], sep="")