var x,z,i,j,m:integer;
o:array[1..10] of integer;
begin
	readln(x);
	readln(z);
	i:=1;
	repeat
		m:=x mod z;
		x:=x div z;
		o[i]:=m;
		inc(i);
	until x>z;
	o[i]:=x;
	for j:=i downto 1 do write(o[j]);
	readln;
end.