n,k=io.read("*n","*n","*l")
a={}
for i=1,n do
    a[i]=io.read("*n")
    if a[i]==1 then
        x=(i-1)//(k-1)+((i-1)//(k-1) and 1 or 0)
        y=(n-i)//(n-k)+((n-i)//(n-k) and 1 or 0)
        print(x+y)
        return
    end
end