while 1: n,b=map(int,raw_input().split());s='' while n:s+=`n%b`;n/=b print s[::-1]