while 1: o='';a,b=map(int,raw_input().split()) while a:o=`a%b`+o;a/=b print o