import sys

input = sys.stdin.readline



n, k = [int(x) for x in input().split()]

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



idx = a.index(1)



left = idx

right = n - (idx + 1)



ans = 10 ** 10



for i in range(k):

    cnt = 1

    left_ = left - i

    right_ = right - (k - 1 - i)

    cnt += left_//(k - 1) + right_//(k - 1) + int(not left_ % (k - 1) == 0) + int(not right_ % (k - 1) == 0)

    ans = min(ans, cnt)



print(ans)

import sys

input = lambda: sys.stdin.readline().rstrip()

 

n, k = list(map(int, input().split()))

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

for i in range(n):

    if a[i] == 1:

        break

left = len(a[:i])

right = len(a[i + 1:])



ans = left // (k - 1) + right//(k - 1) + (left%(k-1) + right%(k-1))//(k-1) + int((left%(k-1) + right%(k-1))%(k - 1) != 0)



print(ans)

import sys

input = sys.stdin.readline
n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
idx = a.index(1)
left = idx
right = n - (idx + 1)
ans = 10**10
for i in range(k):
    cnt = 1
    left_ = left - i
    right_ = right - (k - 1 - i)
    cnt += (
        left_ // (k - 1)
        + right_ // (k - 1)
        + int(not left_ % (k - 1) == 0)
        + int(not right_ % (k - 1) == 0)
    )
    ans = min(ans, cnt)
print(ans)

import sys

input = lambda: sys.stdin.readline().rstrip()
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n):
    if a[i] == 1:
        break
left = len(a[:i])
right = len(a[i + 1 :])
ans = (
    left // (k - 1)
    + right // (k - 1)
    + (left % (k - 1) + right % (k - 1)) // (k - 1)
    + int((left % (k - 1) + right % (k - 1)) % (k - 1) != 0)
)
print(ans)

-input = sys.stdin.readline -n, k = [int(x) for x in input().split()] -a = [int(x) for x in input().split()] -idx = a.index(1) -left = idx -right = n - (idx + 1) -ans = 10**10 -for i in range(k): -    cnt = 1 -    left_ = left - i -    right_ = right - (k - 1 - i) -    cnt += ( -        left_ // (k - 1) -        + right_ // (k - 1) -        + int(not left_ % (k - 1) == 0) -        + int(not right_ % (k - 1) == 0) -    ) -    ans = min(ans, cnt) +input = lambda: sys.stdin.readline().rstrip() +n, k = list(map(int, input().split())) +a = list(map(int, input().split())) +for i in range(n): +    if a[i] == 1: +        break +left = len(a[:i]) +right = len(a[i + 1 :]) +ans = ( +    left // (k - 1) +    + right // (k - 1) +    + (left % (k - 1) + right % (k - 1)) // (k - 1) +    + int((left % (k - 1) + right % (k - 1)) % (k - 1) != 0) +)