x=lambda v,b:v!=0 and x(v/b,b)*10+v%b while 1:print x(*map(int,raw_input().split()))