N,K = list(map(int,input().split()))

A = list(map(int,input().split()))

for i in range(N):

  if A[i] == 1:

    loc = i

    break

#print(loc) #locは0index



left = loc

right = N-(loc+1)



ans = left//(K-1) + right//(K-1)

nokori = left%(K-1) + 1 + right%(K-1)

#print(ans,nokori)

if nokori == 1:

  ans += 0

elif nokori <= K:

  ans += 1

else:

  ans += 2

print(ans) 

N,K = list(map(int,input().split()))

A = list(map(int,input().split()))

n = N-1

k = K-1

ans = (n+k-1)//k

print(ans)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(N):
    if A[i] == 1:
        loc = i
        break
# print(loc) #locは0index
left = loc
right = N - (loc + 1)
ans = left // (K - 1) + right // (K - 1)
nokori = left % (K - 1) + 1 + right % (K - 1)
# print(ans,nokori)
if nokori == 1:
    ans += 0
elif nokori <= K:
    ans += 1
else:
    ans += 2
print(ans)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
n = N - 1
k = K - 1
ans = (n + k - 1) // k
print(ans)

-for i in range(N): -    if A[i] == 1: -        loc = i -        break -# print(loc) #locは0index -left = loc -right = N - (loc + 1) -ans = left // (K - 1) + right // (K - 1) -nokori = left % (K - 1) + 1 + right % (K - 1) -# print(ans,nokori) -if nokori == 1: -    ans += 0 -elif nokori <= K: -    ans += 1 -else: -    ans += 2 +n = N - 1 +k = K - 1 +ans = (n + k - 1) // k