while 1: s=raw_input().split() n=int(s[0]) b=int(s[1]) l=[] while n>=b: l+=[str(n%b)] n=n/b if n>0:l+=[str(n)] l.reverse() print''.join(l)