while 1:a,b=map(int,raw_input().split());c=0;exec"c+=b**c!=a;"*99;print c