peterverebics/CodeNet_Python_118 huggingface dataset:
n,k = map(int,input().split())
lst = list(map(int,input().split()))

id_of_one = lst.index(1) #リスト内の最小値1のインデックスを取得

left = len(lst[0:id_of_one]) #1より左側にある数列の長さ
right = len(lst[id_of_one+1:]) #1より右側にある数列の長さ
total = left + right

amari = max(left%(k-1),right%(k-1))
total -= amari



counter = 0
while total > 0:
    counter += 1
    total -= k - 1

print(counter)
N, K = map(int, input().split())
A = tuple(map(int, input().split()))

a_min = min(A)

pos = 0
ans = 0
while pos < N:
    if A[pos] != a_min:
        pos += K - 1
        ans += 1
    else:
        pos += 1

print(ans)
import math

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    l = r = A.index(1)
    ans = 0
    while r < N-1 or l > 0:
        if r < N-1:
            ans += 1
            r += K-1
        
        if l > 0:
            ans += 1
            l -= K+1

    print(ans)

main()
# coding: utf-8

N, K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    if A[i] == 1:
        cnt = i
        break

a = cnt + 1
b = N - 1 - i + 1
#print(a, b)
m1 = a // (K - 1)
n1 = a % (K - 1)

m2 = b // (K - 1)
n2 = b % (K - 1)
ans = 0

ans += m1 + m2
if n1 > 1:
    ans += 1
if n2 > 1:
    ans += 1
if N <= K:
    ans = 1
print(ans)
N,K = (int(X) for X in input().split())
A  = [int(X) for X in input().split()]
OI = A.index(1)
L = (OI+1)//(K-1)
R = (N-OI)//(K-1)
print(L+R)
import math
N,M = list(map(int,input().split()))
n_l = "".join(input().split())
A = n_l.find("1")
before = math.ceil(A / (M-1))
after = math.ceil((N-A-1) / (M-1))
print(before+after)
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()
K -= 1
i = A.index(1)
# コーナーケース対策
if i <= K:
    i = K + 1
elif i >= (N - K):
    i = N - K - 1
right = (i - 1) // K + 1
left = (N - 1 - i - 1) // K + 1


# print(right, left)
print(right + left)
n, k = map(int, input().split())
A = [int(x) for x in input().split()]
i1 = A.index(1)
ans = 0
tmp = i1
while True:
    if tmp <= 1:
        break
    tmp -= k - 1
    ans += 1
tmp = i1
while True:
    if n <= tmp:
        break
    tmp += k - 1
    ans += 1
print(ans)
N, K = map(int, input().split())
l = list(map(int, input().split()))
index = l.index(1)

ans = 0
if index != 0:
    p = index - K + 1
    ans += 1
    if p < 0:
        index = index + (-1 * p)
    elif p > 0:
        while p > 0:
            p = p - K + 1
            ans += 1
if index < (N - 1):
    ans += 1
    index = index + K - 1
    while index < (N - 1):
        index = index + K - 1
        ans += 1

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

print(N // 2)
import math
N, K = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(N):
    if A[i] == 1:
        ind = i
        break
left = ind
right = N - ind - 1
ans = math.ceil(left / K) + math.ceil(right / K)
print(ans)
import math

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

if(N!=K):
    print(math.ceil(N/(K-1)))
elif((N+1)/K==2):
    print(2)
else:
    print(1)
N,K=map(int,input().split())
A=list(map(int,input().split()))

if K == N:
  print(1)
  exit()
  
MIN = min(A)

argmin=[]
for i in range(N):
  if A[i]==MIN:argmin.append(i)
    
ans = 10**9
for a in argmin:
  SUM=0
  SUM += (a+(K-2)) // (K-1)
  SUM += ((N-1-a)+(K-2))//(K-1)
  if ans > SUM:ans=SUM

print(ans)
listlen, rensuu = map(int, input().split())
listnum = list(map(int, input().split()))
count = 0
count += (listlen - 1) // (rensuu - 1)
count += 1 if (listlen - 1) % (rensuu - 1) > 0 else 0
oneposi = listnum.index(1)
if rensuu < oneposi  + 1 < listlen - rensuu:
    count = len(listnum[:oneposi]) // (rensuu - 1) + len(listnum[oneposi + 1:]) // (rensuu - 1)
print(count)
import math

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k = nm()
a = nl()

for i in range(n):
  if a[i]==1:
    x = math.ceil(i/(k-1))
    y = math.ceil((n-i-1)/(k-1))
    ans = x+y
if n==k:
  ans=1
print(ans)
n, k = map(int,input().split())
a = list(map(int,input().split()))
g=1
while k+(k-1)*(g-1)<= n:
  g+=1
print(g)
from math import ceil

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

# check
if N == K:
    print(1)
else:
    min_idx = A.index(1)

    if min_idx == 0:
        r_cnt = 0
    else:
        r_cnt = ceil(len(A[:min_idx]) / (K - 1))

    if min_idx == N - 1:
        l_cnt = 0
    else:
        l_cnt = ceil(len(A[min_idx + 1:]) / (K - 1))

    print(r_cnt + l_cnt)
n,m=map(int,input().split())
l=list(map(int,input().split()))
print(-(-(len(l)-m)//(m-1)))
import sys
readline = sys.stdin.readline
import math

def main():
    N, K = map(int, readline().rstrip().split())
    A = list(map(int, readline().rstrip().split()))
    mi = A.index(1)
    ans = math.ceil(mi / (K-1)) + math.ceil((N-mi-1) / (K-1))
    print(ans)


if __name__ == '__main__':
    main()
n, k = map(int, input().split())
*a, = map(int, input().split())

i = a.index(1)
mar = k - 1  # max replacible count

le = (i + mar - 1) // mar  # [0,i)
ri = (n - i - 1 + mar - 1) // mar  # [i+1,n)

print(le + ri)
def LI():
	return [ int(s) for s in input().split() ]
  
N,K = LI()
A = LI()
 
for idx,a in enumerate(A):
    if a == 1:
      min_index = idx
      break
      
if N - idx+1 > K and idx+1 > K:
  cnt = 0
  if (N-idx+1)%K == 0:
    cnt += (N-idx+1)//K
  else:
    cnt += (N-idx+1)//K + 1
  if (idx+1)%K == 0:
    cnt += (idx+1)//K
  else:
    cnt += (idx+1)//K + 1
  print(cnt)
else:
  print(N//K + 1) if N%K != 0 else print(N//K)
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
i=a.index(1)
print((i+(k-1)-1)//(k-1)+(n-(i+1))+((k-1)-1)//(k-1))
N, K = map(int, input().split())
A = map(int, input().split())
print(int((N - 1) / 2) + (N - 1) % 2)
n, k = map(int, input().split())
a = list(map(int, input().split()))

if k < n:
    ans = 0
    while n > 0:
        n -= k - 1
        ans += 1
else:
    ans = 1
print(ans)
n, k = map(int, input().split())
A = list(map(int, input().split()))

p = A.index(1)
if p == 0 or p == n-1:
  ans = (n + k - 2) // k
elif p < k-1 or n-k < p:
  ans = 1 + (n-1) // k
else:
  ans = (p + k - 1) // k + (n - p + k) // k

print(ans)
import math
n, k = map(int,input().split())
a = list(map(int,input().split()))
print(math.ceil(n-1)/(k-1))
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
L = A.index(1)
R = N - L - 1
if N == K:
    print(1)
elif L <= K-1  or R <= K-1:
    print(ceil((N-1)/(K-1)))
else:
    ansL = ceil(L/(K-1))
    ansR = ceil((R-max(L%(K-1)-1,0))/(K-1))
    print(ansL + ansR)
n, k = map(int, input().split())
a = list(map(int, input().split()))

idx = a.index(1)


def ceil(a, b):
    return -(-a // b)


print(ceil((idx+1), k) + ceil((n-idx+1), k))
def main():
    n, k = map(int, input().split())
    a_lst = list(map(int, input().split()))
    min_index = a_lst.index(1)

    if min_index - 1 >= 0:
        before = 1 + (min_index - 1) // (k - 1)
    else:
        before = 1

    tmp = n - min_index - 1
    if tmp - 1 >= 0:
        after = 1 + (tmp - 1) // (k - 1)
    else:
        after = 1

    answer = before + after
    print(answer)


if __name__ == '__main__':
    main()
n,k = map(int,input().split())
ls = list(map(int,input().split()))
a = min(ls)
i = ls.index(a)
l = i
r = n - i -1
if l % 2 != 0:
    l += 1
if r % 2 != 0:
    r += 1
print(int((r+l)/2))
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    print(n // (k - 1))

resolve()
n,k=map(int,input().split())
a=list(map(int, input().split()))
for i in range(n):
    if a[i]==1:
        index=i
print((i-1)//2+(n-i)//2+1)
from math import ceil

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

idx = ll.index(1)

l, r = idx, N-idx

print(ceil((l-1)/(K-1))+ ceil((r-1)/(K-1)))
n, k = map(int, input().split())
print(n//(k-1))
import math

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
idx = a.index(1)
l = math.ceil(idx / (k - 1))
r = math.ceil((n - idx - 1) / (k - 1))
print(l + r)
n,k=map(int,input().split())
a=[int(x) for x in input().split()]

print(n//(k-1))
A = list(map(int, input().split()))
B = input()
if A[0]%2 == 0:
    A[0] += 1
ans = A[0] // (A[1]-1)
if ans == 0:
    ans = 1
print(ans)
n, k = map(int, input().split())
a = list(map(int, input().split()))
x = a.index(1)
left = x
right = n - x - 1

ans = n
for i in range(k):
    if left < i:
        continue
    a = left - i + 1
    if right - k + 2 + i < 0:
        continue
    b = right - k + 2 + i
    w = a//(k-1) + b//(k-1)
    ans = min(ans, w)
print(ans + 1)
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=1000000
for i in range(n):
  if a[i]==1:
    x=i+1

b=x-1
c=n-x
ans=0
if b%2==0:
  ans+=b//2
else:
  ans+=b//2+1
if c%2==0:
  ans+=c//2
else:
  ans+=c//2+1
print(ans)
#!usr/bin/env python3
N, K = map(int, input().split())    
A = list(map(int, input().split()))
#print(N, K, A)

print(N//(K-1))
def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = []
    for x in range(1, N+1):
        if x > (N-1-K)/(K-1) and x <= (N-1)/(K-1):
            ans.append(x)
    print(min(ans))
main()
import math

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

m = min(lis)

if n == k:
    print(1)
elif lis[0] == m or lis[n-1] == m:
    print(math.ceil(n/(k-1))-1)
else:
    print(math.ceil(n/(k-1)))
import math

N, K = map(int, input().split())
A = list(input().split())
A_lis = [int(A[i]) for i in range(N)]

index = A_lis.index(1)

if N == K:
    print(1)
else:
    print(math.ceil(index / (K-1)) + math.ceil((N-index-1) / (K-1)))
# coding: utf-8

N, K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    if A[i] == 1:
        cnt = i
        break

a = cnt + 1
b = N - 1 - i + 1
#print(a, b)
m1 = a // (K - 1)
n1 = a % (K - 1)

m2 = b // (K - 1)
n2 = b % (K - 1)
ans = 0

ans += m1 + m2
if n1 > 1:
    ans += 1
if n2 > 1:
    ans += 1

print(ans)
N,K = (int(X) for X in input().split())
A  = [int(X) for X in input().split()]
OI = A.index(1)
if OI==0 or OI==(N-1):
    print(N//(K-1))
else:
    L = max(1,(OI+1)//(K-1))
    R = max(1,(N-OI)//(K-1))
    print(L+R)
import math
N,K=map(int,input().split())
if N==K:
    print(1)
else:
    print(math.ceil((N+K-1)/K))
import math
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

if(K-1 == 1):
  print(N - 1)
elif(K == N):
  print(1)
else:
  print(N // (K - 1))
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
c=0
mn=min(l)
while len(l)>=1:
  if mn==min(l):
    m=l.index(min(l))
    if m!=0:
      c+=m//(k-1)
      if m%(k-1)!=0:
        c+=1
    l=l[m+1:]
  else:
    c+=len(l)//(k-1)
    if len(l)%(k-1)!=0:
      c+=1
    l=[]
print(c)
import sys
from math import ceil

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, K = in_nn()
    readline()

    ans = ceil(N / (K - 1))
    if N % (K - 1) == 1:
        ans -= 1

    print(ans)


if __name__ == '__main__':
    main()
n,k=map(int,input().split())
n=n-k
if n<=k:print(1)
else:
	n=n-k
	r=list(map(int,input().split()))
	if n%(k-1)==0:print(1+n//(k-1))
	else:print(2+n//(k-1))
#!/usr/bin/env python3
import math

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

index = a.index(1)

pre = index
post = n-index-1

ans = 0
ans += math.ceil(pre/(k-1))
ans += math.ceil(post/(k-1))

print(ans)
n,k = map(int,input().split())
l = list(map(int,input().split()))
a = l.index(1)
left = -(-a//2)
right = -(-(n-a)//2)
print(left+right)
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, K = in_nn()
    readline()

    q, r = divmod(N, K - 1)
    if r in (0, 1):
        ans = q
    else:
        ans = q + 1

    print(ans)


if __name__ == '__main__':
    main()
n, k = map(int, input().split())
print((n - 1) // (k - 1))
n, k = map(int, input().split())
a = list(map(int , input().split()))
idx = a.index(1)
l = idx + 1
r = n - idx
if n == k:
    print(1)
    exit()
ln = 1
if l == 1:
    ln = 0
elif l >= k:
    ln = l // (k-1)
rn = 1
if r == 1:
    rn = 0
elif r >= k:
    rn = r // (k-1)

print(ln + rn)
def main():
    n, k = map(int, input().split())
    a_lst = list(map(int, input().split()))
    min_index = a_lst.index(1)

    if min_index - 1 >= 0:
        before = 1 + (min_index - 1) // 2
    else:
        before = 1

    tmp = n - min_index - 1
    if tmp - 1 >= 0:
        after = 1 + (tmp - 1) // 2
    else:
        after = 1

    answer = before + after
    print(answer)


if __name__ == '__main__':
    main()
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

minpos = 0
for i in range(0, n):
  if a[i] == 1: minpos = i
print((minpos + k - 2) / (k - 1) + (n - minpos - 1 + k - 2) / (k - 1))
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
ind = A.index(1)
L = ind
R = N - L - 1
if N == K:
    print(1)
else:
    if L > 0:
        ansL = ceil(L/(K-1))
    else:
        ansL = 0
    if R > 0:
        ansR = ceil((max(L%(K-1)-1,0) + R)/(K-1))
    else:
        ansR = 0
    print(ansL + ansR)
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
if N == K:
    print(1)
if K == 2:
    print(N-1)
else:
    ans = ceil(N/(K-1))
    print(ans)
import math
n,k = map(int,input().split())
ls = list(map(int,input().split()))
a = min(ls)
i = ls.index(a)
l = i
r = n - i - 1
if r < l:
    l,r = r,l
if n == k:
    print("1")
elif l < k-1:
    print(int(math.ceil((r-k+1+l)/(k-1)))+1)
else:
    print(int(math.ceil(l/(k-1))+math.ceil(r/(k-1))))
N, K = map(int, input().split())
l = list(map(int, input().split()))
index = l.index(1) + 1

ans = 0
# 0よりも左があるなら左を計算
if index != 1:
    p = index - K
    ans += 1
    if p < 0:
        index = K
    p += 1
    while p > 0:
        p = p - K
        ans += 1
# 0よりも右があるなら右を計算
while index < N:
    index = index + (K - 1)
    ans += 1

print(ans)
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
now = a.index(1)
r = n-now-1
l = now
if l <= k-1 or r <= k-1:
        print(math.ceil(n/(k-1)))
else:
        print(math.ceil(l/(k-1))+math.ceil(r/(k-1)))
n, k = map(int, input().split())
_ = input()

count = 0
for i in range(0, n, k - 1):
    count += 1
print(count)
import math

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]
idx = a.index(1)
num_l = idx
num_r = n - idx - 1
ans = math.ceil(num_l / (k-1)) + math.ceil(num_r / (k-1))
print(ans)
N,K=map(int,input().split())
A=list(map(int,input().split()))

print(((N-1)+(K-1))//(K-1))
import math
N, K = map(int, input().split())
A_list = [int(i) for i in input().split()]

index = A_list.index(1)

left_list = A_list[:index]
right_list = A_list[index+1:]

left_count = math.ceil(len(left_list) / (K-1))
right_count = math.ceil(len(right_list) / (K-1))

print(left_count + right_count)
n,k=map(int,input().split())
a = list(map(int,input().split()))
cnt = 0

if n % k == 0:
  cnt = int(n / k)
else:
  while n > 0:
    n = n - (k-1)
    cnt +=1
  
print(cnt)
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N==K:
    print(1)
    exit(0)
index = A.index(1)
ans = math.ceil((N-1-index)/(K-1)) + math.ceil(index/(K-1))

print(ans)
def solve():
    cnt = (N - 1) // (K - 1) + 1
    if N == K:
        cnt = (N - 1) // (K - 1)
    print(cnt)

if __name__ == "__main__":
    N,K = list(map(int, input().split()))    
    a = list(map(int, input().split()))
    solve()
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    print(n // (k - 1))

    
if __name__ == '__main__':
    main()
n, k = map(int, input().split())
a = list(map(int, input().split()))
one_index = a.index(1)

l = one_index
r = n - 1 - one_index

res = (l + (k - 1 - 1)) // (k - 1) + (r + (k - 1 - 1)) // (k - 1)
print(res)
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
L = A.index(1)
R = N - L - 1
if N == K:
    print(1)
elif L == 0 or R == N-1:
    print((N-1)%(K-1))
else:
    ansL = ceil(L/(K-1))
    ansR = ceil((max(L%(K-1)-1,0) + R)/(K-1))
    print(ansL + ansR)
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
a = LI()
for i in range(n):
    if a[i] == 1:
        idx = i
        break
ans = (idx-1) // (k-1) + (n-2-idx) // (k-1) + 2
print(ans)
n,k = map(int,input().split())
a = list(map(int,input().split()))
print(n//(k-1))
n,k=map(int,input().split())
a = list(map(int,input().split()))

if n % k == 0:
  print(int(n/k))
else:
  print(int(n/(k-1)))
import sys
import math

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

if N == K:
    print(1)
    sys.exit()
for i in range(N):
    if A[i] == 1:
        print(math.floor((i+1)/(K-1)) + math.ceil((N-i-1)/(K-1)))
        break
N,K = map(int,input().split())
A = list(map(int,input().split()))

N -= 1
K -= 1
print(N // K)
import math
N, K = map(int,input().split())
A = list(map(int,input().split()))
print(math.ceil(N/(K-1)))
n,k = map(int,input().split())
a_list = list(map(int,input().split()))
if n == k:
    print(1)
    
else:
    print((n+k-2)//(k-1))
# coding: utf-8

N, K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    if A[i] == 1:
        cnt = i
        break

a = cnt + 1
b = N - 1 - i + 1
#print(a, b)
m1 = a // (K - 1)
n1 = a % (K - 1)

m2 = b // (K - 1)
n2 = b % (K - 1)
ans = 0
print(m1, m2)
ans += m1 + m2
if n1 > 1:
    ans += 1
if n2 > 1:
    ans += 1
if N <= K:
    ans = 1
if K == 2:
    ans = 0
    ans += a - 1
    ans += N - 1 - cnt
print(ans)
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
if N == K:
    print(1)
elif K == 2:
    print(N-1)
else:
    ans = ceil(N/(K-1))
    print(ans)
N, K = map(int, input().split())
A = list(map(int, input().split()))
k = A.index(1)
print((k + K - 2) // (K - 1) + (N - k - 1 + K - 2) // (K - 1))
import math
N, K = map(int, input().split())
arr = list(map(int, input().split()))

if N == K:
    print(1)
    exit()

mae = arr.index(1)
usiro = len(arr)-1-arr.index(1)
print(math.ceil(mae/(K-1))+math.ceil(usiro/(K-1)))
n,k = map(int,input().split())

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])
#print(left_length)
right_length = len(lst[id_one:])-1
#print(right_length)
counter = 0


if min(left_length,right_length) < k-1:
    if left_length < right_length:
        right_length -= left_length%(k-1)
    else:
        left_length -= right_length%(k-1)


while left_length > 0:
    counter += 1
    left_length -= k-1


while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)
from math import ceil
n,k=map(int,input().split())
if n <= k:
  print(1)
  quit()
A=list(map(int,input().split()))
ind = A.index(1)
ans = ceil(ind/k)+ceil((n-ind+1)/k)
print(ans)
n, k = map(int, input().split())
a = list(map(int, input().split()))
mini = a.index(1)
l = mini // (k-1)
lm = mini % (k-1)
r = (n - mini - 1) // (k-1)
rm = (n - mini - 1) % (k-1)
# print(l, r, lm, rm)
print(l + r + ((lm + rm + 1) // (k-1)))
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))

i = A.index(1)
left = i
right = N - i - 1

cnt = math.ceil(left / (K - 1)) + math.ceil(right / (K - 1))

print(cnt)
import math


def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    if len(A) <= K:
        print(1)
        return

    min_index = A.index(1)

    before = len(A[min_index:])
    after = len(A[min_index + 1:])
    ans = math.ceil(before / K) + math.ceil(after / K)

    print(ans)


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

x = N-K
x, m = divmod(x, (K-1))
print(1+x+m)
from math import ceil
n,k = map(int, input().split())
a = list(map(int, input().split()))

p = a.index(1)
ans = ceil(p/(k-1))
ans += ceil((n-1-p)/(k-1))
print(ans)
N, K = map(int, input().split())
A = tuple(map(int, input().split()))

a_min = min(A)

c = 0
ans = 0
for idx, a in enumerate(A):
    if a == a_min:
        if c > 0:
            ans += (c+K-2)//(K-1)
            c = 0
    else:
        c += 1

if c > 0:
    ans += (c+K-2)//(K-1)

print(ans)
import sys
input = sys.stdin.readline

def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    x = A.index(1)
    print(-(-x // (K - 1)) + -(-(N - x - 1) // (K - 1)))




if __name__ == '__main__':
    main()
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
ind=10**7
ans=0
for i in range(n):
  if a[i]==1:
    ind=i
ans+=math.ceil(ind/(k-1))+math.ceil((n-ind)//(k-1))

print(ans)
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
print(int(n/(k-1)))
n,k=[int(x) for x in input().rstrip().split()]
a=[int(x) for x in input().rstrip().split()]
now=0
ans=0
if n==k:
  print(1)
else:
  while(0<n):
    n-=k
    n+=1
    ans+=1
  print(ans)
n,k = map(int,input().split())
a = (n-1)//(k-1)
if (n-1)%(k-1) == "0":
    print(a)
else:
    print(a+1)
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[i]==1:
    ind=i
ans+=math.ceil(ind/(k-1))+math.ceil((n-ind-1)/(k-1))

print(ans)
import sys
import math

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

for i in range(N):
    if A[i] == 1:
        print(math.ceil(i/(K-1)) + math.ceil((N-i-1)/(K-1)))
        break
N,K=map(int,input().split())
*A,=map(int,input().split())

now=A.index(1)


now_l=now
now_r=now
ans=0
while now_l>0:
    now_l-=K-1
    ans+=1
while now_r<N-1:
    now_r+=K-1
    ans+=1

print(ans)
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力を取得
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

# 求解処理
x = A.index(1)
y = N - x - 1
ans = math.ceil(x / (K - 1)) + \
    math.ceil((y - ((K - 1) - x % (K - 1))) / (K - 1))

# 結果出力
print(ans)
import sys
input = sys.stdin.readline


def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    index_1 = A.index(1)
    left = (index_1 + k - 2) // (k - 1)
    right = (n - 1 - index_1 + k - 2) // (k - 1)
    print(left + right)


if __name__ == "__main__":
    main()
n, k = map(int, input().split())
A = tuple(map(int, input().split()))
idx1 = A.index(1)

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

print((N-1)//(K-1))
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k, *a = map(int, read().split())
    pos = a.index(1)
    mae = ceil(pos / (k - 1))
    ushiro = ceil((n - 1 - pos) / (k - 1))
    r = mae + ushiro
    print(r)

if __name__ == '__main__':
    main()
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(int((N - 1) / (K - 1)) + (N - 1) % (K - 1))
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = (n-1)/(k-1)#切り上げ
if ans % 1 == 0:
  print(int(ans))
else:
  print(ans // 1 + 1)