Program jzzh;
const maxs = 100;
const stri:string = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var
n,k,s,i:integer;
a:array[0..maxs-1] of integer;
begin
readln(n,k); {从键盘读入n和k}
s:=0;
while( n>0 )do
begin
a[s] := n mod k;
n := n div k;
inc(s);
end;
for i:=s-1 downto 0 do
write( stri[a[i]+1]);
end.