N, K = [int(x) for x in input().split()]

A_lst = [int(x) for x in input().split()]

r = -1

l = -1

for i in range(N):

    if A_lst[i] == 1:

        r = i

        l = N - i - 1

print(((r + l + K - 2)//(K - 1)))

N, K = [int(x) for x in input().split()]

print(((N + K - 3)//(K - 1)))

N, K = [int(x) for x in input().split()]
A_lst = [int(x) for x in input().split()]
r = -1
l = -1
for i in range(N):
    if A_lst[i] == 1:
        r = i
        l = N - i - 1
print(((r + l + K - 2) // (K - 1)))

N, K = [int(x) for x in input().split()]
print(((N + K - 3) // (K - 1)))

-A_lst = [int(x) for x in input().split()] -r = -1 -l = -1 -for i in range(N): -    if A_lst[i] == 1: -        r = i -        l = N - i - 1 -print(((r + l + K - 2) // (K - 1))) +print(((N + K - 3) // (K - 1)))