n,k=map(int,input().split()) total=0 while n>0: total+=n n//=k print(total)
------Input------ 159 16 ------Answer----- 169 ------Your output----- 168