  Program Main

    Implicit None
    Integer(8)           :: N,K,M,digit

    N = 0
    K = 0
    M = 0
    digit = 1
    Read(*,*) N,K
    M = K
    N = N - M
    If (N == 0) digit = digit + 1 
    M = M*(K-1)
    If (N>0)then
       Check:Do 
                digit = digit + 1
                N = N - M 
                If (N <= 0) then
                   Exit Check
                Elseif (N == 0) then
                   digit = digit + 1
                   Exit Check
                Endif
                M = M*K
             Enddo Check
    Endif

    Write(*,"(I0)") digit

  End Program
