program sample
    implicit none
  
    integer(8) :: i,j,m,n,a,b,c,k
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n,k
    allocate(x(n))
    read(*,*)x
    do i=1,n
        if(x(i)==1)then
            a=i
            exit
        endif
    end do
    k=k-1
    j=0
    if(mod(a-1,k)==0)then
        b=(a-1)/k
        c=0
    else
        b=(a-1)/k+1
        c=mod(a-1,k)
        j=1
    end if
    if(mod(n-a,k)==0)then
        b=b+(n-a)/k
    else
        b=b+(n-a)/k+1
        c=c+mod(n-a,k)
        j=j+1
    end if
    if(j==2)then
        b=b-1
    end if

    write(*,*) b  
    stop
end program sample
  

