begin repeat var a,b,c,d:comp=1;read(a,b);repeat c:=a mod b*d+c;a:=a div b;d:=d*10until a=0;writeln(c-1)until 1=0end.