begin repeat var x,y,z,n:comp=1;read(x,y);repeat n:=n+x mod y*z;x:=x div y;z:=z*10until x=0;writeln(n-1)until 0>0end.