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