exec's="";n,r=map(int,raw_input().split())\nwhile n:s=str(n%r)+s;n/=r\nprint s;'*99