local N,M,a,b,c,e,f=io.read,tostring,tonumber,string.sub,'',''N,M=M(N('*n')),M(N('*n'))for g=1,#N do if'.'==b(N,g,g)then f=g-1 break end end for g=1,#N do if(f or#N)-g<3 then break end local h,i=a(c..b(N,g,g))c,i=h,math.floor(h/M)if i~=0 or#e>0 then e,c=e..i,c%M end end e=e..(a(e)and'000'or 0)print(e)