peterverebics/CodeNet_Python_118 huggingface dataset:
def resolve():
    N, K = list(map(int, input().split(" ")))
    A = list(map(int, input().split(" ")))
    i = A.index(1)
    import math
    print(math.ceil(len(A[:i])/(K-1)) + math.ceil(len(A[i+1:])/(K-1)))

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

place_1 = A.index("1")
L = place_1
R = n - L - 1

print(-(-L//(k-1)) + -(-R//(k-1)))
import math

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

if n == k:
    print(1)
    exit()

idx = a.index(1)
print(math.ceil(idx / (k-1)) + math.ceil((n - idx - 1) / (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 - (index % (K-1))) / (K-1)))
import math

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

ans = math.ceil(n/k)

print(ans)
S = input().split(" ")
N = int(S[0])
K = int(S[1])
ARR = input().split(" ")



import re
import math

def calculate(n,k,arr):
    miniest = int(min(arr))

    s = "".join(arr)
    brr = re.split(str(miniest)+'{1,}',s)

    counts = 0

    for br in brr:
        counts += math.ceil(len(br) / (k-1))

    return counts

result = calculate(N,K,ARR)

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

ind = a.index(1)
cnt = k - 1
ans = 0
for i in reversed(range(ind + 1)):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

if n > k:
    cnt = k - 1
for i in range(ind, n):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

print(ans)
n,k=map(int,input().split())
a=list(map(int,input().split()))
z=a.index(1)
L= -(-z//(k-1))
R=-(-(n-z-1)//(k-1))
print(L+R)
import math
n, k = map(int,input().split())
a = list(map(int,input().split()))
ans = math.ceil(n/(k-1))
print(ans)
import math

N, K = map(int,input().split())
l = list(map(int,input().split()))
tag = l.index(1)

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

min_index = li.index(1)
left = min_index
right = len(li) - left - 1

count = 0

if (left > 0) :
    count += left // (K-1)
    if (left % (K-1) == 1) :
        count += 1

if (right > 0) :
    count += right // (K-1)
    if (right % (K-1) == 1) :
        count += 1

print(count)
import math 

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

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

print(math.ceil(n/k))
n,k = [int(x) for x in input().split()]
print(1 + (n-k)%(k-1))
import math
n, k, *nums = map(int, open(0).read().split())
print(math.ceil((n-k)/2)+1)
N,K = map(int,input().split())
A = list(map(int,input().split()))

P = K - 1
print(N // P)
import numpy as np
N,K = map(int,input().split())
an = list(map(int,input().split()))

min_an_index = np.argmin(an)

a = min_an_index
b = N - min_an_index - 1

if K > a:
    b -= K - a - 1
if K > b:
    a -= K - b - 1
    
a1 = a // (K-1)
if a % (K-1) != 0:
    a1 += 1
    
b1 = b // (K-1)
if b % (K-1) != 0:
    b1 += 1

count = a1 + b1
print(count)
N,K = (int(X) for X in input().split())
A  = [int(X) for X in input().split()]
Left  = A.index(1)
Right = (N-1)-Left
Count = (Right%(K-1)!=0)+Right//2
Left  -= min(0,Right%(K-1))
Count += (Left%(K-1)!=0)+Left//2
print(Count)
N, K = map(int, input().split())
A = list(map(int, input().split()))

a_min = min(A)

pos = 0
ans = 0

for pos in range(N):
    if A[pos] != a_min:
        for i in range(pos, min(pos+K-1, N)):
            A[i] = a_min
        ans += 1

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

#A.sort()
arr = []
for i in range(1,K):
    if N % i == 0:
        arr.append(i)
#print(arr)

tmp = max(arr)
#print(tmp)
if N==K:
    tmp = N
print(N//tmp)
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+1)/k)+ceil((n-ind+1)/k)
print(ans)
#基本全部1にする
import math
n,k = list(map(int, input().split()))
As = list(map(int,input().split()))
pos = As.index(1)
#print(pos)
pos_b = math.ceil((n-1-pos)/(k-1))
pos_f = math.ceil(pos/(k-1))
print(pos_b+pos_f)
from math import ceil

n, k = map(int, input().split())
a = list(map(int, input().split()))
idx = a.index(1)
if idx == 0:
    print(ceil(len(a[(idx + 1):]) / (k - 1)))
elif idx == (n - 1):
    print(ceil(len(a[:idx]) / (k - 1)))
else:
    print((ceil(len(a[:idx]) / (k - 1))) + (ceil(len(a[(idx + 1):]) / (k - 1))))
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N == K:
    print(1)
else:
    print(math.ceil(N/(K-1)))
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 + ((lm + rm + 1) % k != 0)))
import math
n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]


def get_1_index(a):
    for i,j in enumerate(a):
        if j==1:
            return i


index=get_1_index(a)

mae=index
usiro=n-index-1

print(math.ceil(mae/(k-1))+math.ceil(usiro/(k-1)))
n,k=map(int,input().split())
l=list(map(int,input().split()))
for i in range(n):
  if l[i]==1:
    tmp=i
print(tmp//2+(n-tmp)//2)
# 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)

# 怒りの全探索
ans = 0
for j in range(0, N, K):
    ans += 1

print(ans)
N,K = map(int,input().split())
A = list(map(int,input().split()))
B = A.index(1)
#print(B)
ans = 0
C = B
if K == N:
    print(1)
else:
    while C < N:
        C += K - 1
        ans += 1
    while B > 0:
        B -= K - 1
        ans += 1
    print(ans)
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:
    left = math.ceil(index / (K-1))
    leftamari = index % (K-1)
    right = math.ceil(max(0, N - K - index + leftamari) / (K-1))
    print(left + right)
N,K = map(int,input().split())
A = list(map(int,input().split()))

index = A.index(1)
cnt = 1

right = 0
left = 0

if (N-1)//2 < index:
    right = N-1-index
    left = index-(K-1)
else:
    left = index
    right = N-1-index-(K-1)

if left%(K-1) == 0:
    cnt += left//(K-1)
else:
    cnt += left//(K-1)+1
if right%(K-1) == 0:
    cnt += right//(K-1)
else:
    cnt += right//(K-1)+1

print(cnt)
n,m=map(int,input().split())
l=list(map(int,input().split()))
print(-(-int(len(l)-m/m-1)))
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
ans=1
n-=k
ans+=(n+k-1)//k
print(ans)
import math

def process_smaller_index(K, min_index):
    if min_index == 0:
        return 0
    else:
        return math.ceil(min_index / K)

def process_larger_index(last_index, K, min_index):
    if min_index == last_index:
        return 0
    else:
        return math.ceil((last_index - min_index) / K)

N, K = map(int, input().split())
A = [int(i) for i in input().split()]
min_index = A.index(1)
print(process_smaller_index(K - 1, min_index) + process_larger_index(len(A)-1, K - 1, min_index))
n, k = map(int, input().split())
a = list(map(int, input().split()))

if n == k:
    print(1)
elif k == 2:
    print(n-1)
else:
    print(n // (k-1))
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
m = 0
for i in range(n):
  if a[i] == 1:
    m = i
    break
print(math.ceil(i/(k-1))+math.ceil((n-i)/(k-1)))
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N,K = I()
A = l()
i = A.index(1)
print(math.ceil(i/(K-1))+math.ceil((N-i-1)/(K-1)))
n,k=map(int,input().split())
a=list(map(int,input().split()))
if n<k:
    print(1)
else:
    print(n//(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+1])-1
right_length = len(lst[id_one:])-1

counter = 0



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


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

print(counter)
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N == K:
    print(1)
elif K == 2:
    print(N-1)
else:
    print(math.ceil(N/(K-1)))
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18

n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    if a[i] == 1:
        start = i
        break
start += 1
r = n - start + 1
l = start
print(r//(k-1) + l//(k-1))
import math
N,K = map(int,input().split())
lsA = list(map(int,input().split()))
P = lsA.index(1)
ans = math.ceil(P/(K-1)) + math.ceil((N-1-P)/(K-1))
print(ans)
n,k=map(int,input().split())
a=list(map(int,input().split()))

print(n//(k-1))
N, K = map(int,input().split())
list_ai = map(int,input().split())
print(((N-1)//(K-1))+1)
N, K = map(int, input().split())
arr = list(map(int, input().split()))
index = arr.index(1)
left = -(-index//2)
right = -(-(N - (index + 1))//2)
print(left+right)
n, k = map(int, input().split())
a = list(map(int, input().split()))

ind = a.index(1)
cnt = k - 1
ans = 0
for i in reversed(range(ind)):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

for i in range(ind, n):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

print(ans)
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 1
if N == K:
    print(1)
    exit()
else:
    if (N-K+1)%K == 0:
        ans += N-K+1
    else:
        ans += (N-K+1)%K+1
print(ans)
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(l, r)
print(ceil((l)/(K-1))+ ceil((r-1)/(K-1)))
N,K=map(int,input().split())
a=list(map(int,input().split()))
index=a.index(1)
l=index
r=index
cnt=0
while l!=0:
  l=max(0,l-K+1)
  cnt+=1
while r!=N-1:
  r=min(N-1,r+K-1)
  cnt+=1
print(cnt)
N, K = map(int, input().split())
A = list(map(int, input().split()))

idx = 0
for i in range(N):
  if A[i] == 1:
    idx = i
    break

ans = 0
# Left
if (N-idx-K) % (K-1) == 0:
  ans += (N-idx-K)//(K-1)+1
else:
  ans += (N-idx-K)//(K-1)+1+1
# Right
if ((idx+1)-K) % (K-1) == 0:
  ans += ((idx+1)-K)//(K-1)+1
else:
  ans += ((idx+1)-K)//(K-1)+1+1
print(ans)
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,k = readInts()
    A = readInts()

    Alen = len(A)
    nokori = Alen - k
    print(1 + nokori // (k-1) + nokori % (k-1))




if __name__ == '__main__':
  main()
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)
    l = -((-x) // (K - 1))
    lmod = (x + 1) % K
    r = -(-(N - x - 1 - lmod) // (K - 1))
    print(l + r)




if __name__ == '__main__':
    main()
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
# print(N, K, A)

answer = N / (K - 1)

print(answer)
n, k = map(int, input().split())
a = [int(i) for i in input().split()]

if len(a) == k:
  print(1)
  exit()

print(((len(a)-1) //( k -1)) + 1)
import numpy as np
N,K = map(int,input().split())
an = list(map(int,input().split()))

min_an_index = np.argmin(an)

a = min_an_index
b = N - min_an_index - 1

a1 = a // (K-1)
if a % (K-1) != 0:
    a1 += 1
    
b1 = b // (K-1)
if b % (K-1) != 0:
    b1 += 1

count = a1 + b1
print(count)
import numpy as np
N,K = map(int,input().split())
an = list(map(int,input().split()))

min_an_index = np.argmin(an)

a = min_an_index
b = N - min_an_index - 1

if K > a:
    b -= K - a - 1
    if b < 0:
        b = 1
if K > b:
    a -= K - b - 1
    if a < 0:
        a = 1
        
a1 = a // (K-1)
if a % (K-1) != 0:
    a1 += 1
    
b1 = b // (K-1)
if b % (K-1) != 0:
    b1 += 1

count = a1 + b1
print(count)
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=a.index(min(a))
print(math.ceil(b/(k-1))+math.ceil((n-b-1)/(k-1)))
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
if k >= n:
    print(1)
    exit()
s = a.index(1)
left = s
right = n - (s + 1)
print(math.ceil(left / (k-1)) + math.ceil(right / (k-1)))
N, K = map(int, input().split())
A = list(map(int, input().split()))

print(N // (K-1))
import numpy as np
N,K = map(int,input().split())
an = list(map(int,input().split()))

min_an_index = np.argmin(an)

a = min_an_index
b = N - min_an_index - 1

if K >= a:
    b -= K - a - 1
    if b < 0:
        b = 1
if K >= b:
    a -= K - b - 1
    if a < 0:
        a = 1
        
a1 = a // (K-1)
if a % (K-1) != 0:
    a1 += 1
    
b1 = b // (K-1)
if b % (K-1) != 0:
    b1 += 1

count = a1 + b1
print(count)
N,K=map(int,input().split())
A=list(map(int,input().split()))
M=K-1
if N%M==0:
    print(N//M)
else:
    print(N//M+1)
import math

def read_ints():
    return[int(i) for i in input().split()]

def main():
    n, k = read_ints()
    print(math.ceil(n / k))

if __name__ == '__main__':
    main()
NK = list(map(int,input().split()))
A = list(map(int,input().split()))
N = NK[0]
K = NK[1]

# print(N)
# print(K)
# print(A)

min_index = A.index(min(A))
# print(min_index)

leftLength = min_index
rightLength = N - 1 - leftLength
# print(leftLength)
# print(rightLength)

delta = K - 1
# print(delta)

count = 0
leftTimes = leftLength // delta
remain = leftLength % delta
if remain > 0:
    leftTimes = leftTimes + 1
    rightLength = rightLength - remain

rightTimes = rightLength // delta
remain = rightLength % delta
if remain > 0:
    rightTimes = rightTimes + 1

count = leftTimes + rightTimes

print(count)
import math

n, k = map(int, input().split())
aa = tuple(map(int, input().split()))

p = 0
for i in range(n):
    if aa[i] == 1:
        p = i
        break

x = 0
k -= 1
x += math.ceil(p / k)
x += math.ceil((n - p - 1) / k)
print(x)
N,K = list(map(int,input().split()))
n=(N-K)//(K-1)+1
mod=(N-K)%(K-1)
print(n+1)
n,k = map(int,input().split())
a = list(map(int,input().split()))
p = min(a)
ans = 0
indl = [-1,n]
for i in range(n):
  if a[i]==p:
    indl.append(i)
indl.sort(reverse=True)
for i in range(len(indl)-1):
  ans += (indl[i]-indl[i+1]-1)//(k-1)+((indl[i+1]-indl[i]-1)%(k-1)!=0)
print(ans)
import math

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

if n == k:
    print(1)
else:
    print(math.ceil(n/(k-1)))
n,k = map(int,input().split())
a = list(map(int,input().split()))

idx = a.index(1)

print(-(-idx // (k-1)) - (-(n - idx - 1) // (k-1)))
N, K = map(int, input().split())
l = list(map(int, input().split()))
index = l.index(1)

ans = 0
if index != 0:
    p = (index + 1) - K
    ans += 1
    if p < 0:
        index = K - 1

    while p > 0:
        p = p - K
        ans += 1

while index < (N - 1):
    index = index + K - 1
    ans += 1

print(ans)
from math import ceil
 
n, k = map(int, input().split())
a = list(map(int, input().split()))
idx = a.index(1)
if idx == 0:
    print(ceil(len(a[(idx + 1):]) / (k - 1)))
elif idx == (n - 1):
    print(ceil(len(a[:idx]) / (k - 1)))
else:
    ans = (ceil(len(a[:idx]) / (k - 1))) + (ceil(len(a[(idx + 1):]) / (k - 1)))
    if (k - 1) < len(a[:idx]) % (k - 1) + len(a[(idx + 1):]) % (k - 1):
        ans -= 1
    print(ans)
n, k = map(int, input().split())
As = list(map(int, input().split()))

if n == k:
    print(1)
    exit()
for i in range(10000):
    # print(i * (k - 1) + k)
    # print((i + 1) * (k - 1) + k)
    if i * (k - 1) + k < n and n <= (i + 1) * (k - 1) + k:
        print(i+2)
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)
ans = math.ceil(mae/(K-1))+math.ceil(usiro/(K-1))

if arr[0] ==1 or arr[-1] ==1:
    print(ans-1)
    exit()
else:
    print(ans)
n, k = map(int, input().split())
a = list(map(int , input().split()))

if n == k:
    print(1)
    exit()

print((n + (n // k)) // (k-1))
N,K = (int(X) for X in input().split())
A  = [int(X) for X in input().split()]
Left  = A.index(1)
Right = (N-1)-Left
Count = (Right%(K-1)!=0)+Right//2
Left  -= Right%(K-1)
Count += (Left%(K-1)!=0)+Left//2
print(Count)
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

m = (n) // (k-1)
print(m)
# 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)
import math
n, k = map(int,input().split())
input()
print(int(math.ceil((n - 1)//(k - 1))))
n,k=map(int,input().split())
k-=1
r=list(map(int,input().split()))
a=r.index(1)
b=n-a-1
print((a+k-1)//k+(b+k-1)//k)
import math
n,k = map(int,input().split())

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

aleft = alist[:alist.index(1)]
aright = alist[alist.index(1)+1:]

ans = math.ceil(len(aleft)/(k-1)) + math.ceil(len(aright)/(k-1))
print(ans)
n,k = map(int, input().split())
A = list(map(int, input().split()))

m = min(A)
i = A.index(m)
k -= 1
cnt = 0
left = i
right = n-1-i
cnt += -(-left//k)
cnt += -(-right//k)
print(cnt)
n,k = map(int, input().split())
A = list(map(int, input().split()))

m = min(A)
i = A.index(m)
cnt = 0
cnt += -(-(i-1)//(k-1))
cnt += -(-n+i)//(k-1)

print(cnt)
n, k = map(int, input().split())
print(n // (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  or R <= K:
    print(ceil((N-1)/(K-1)))
else:
    ansL = ceil(L/(K-1))
    ansR = ceil(R/(K-1))
    print(ansL + ansR)
import math
n, k = map(int, input().split())
A = list(map(int, input().split()))

index = A.index(1)

right_num = n - 1 - index
left_num = index

ans = math.ceil(right_num / (k-1))
ans += math.ceil(left_num / (k-1))

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

minA = min(A)
count_minA = sum([x == minA for x in A])

n_target = N - count_minA
n_1 = n_target // (K - 1)
n_2 = n_target % (K - 1)
y = n_1 + n_2
print(y)
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 n == k:
    print("1")
else:
    print(int(math.ceil(l/(k-1))+math.ceil(r/(k-1))))
N,K = map(int,input().split())
A = list(map(int,input().split()))
B = A.index(1)
#print(B)
ans = 0
C = B
if K == N:
    print(1)
else:
    print(N//(K-1))
# ABC101 C - Minimization
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
r = ceil((N - (A.index(1)+1)) / (K-1))
l = ceil(A.index(1) / (K-1))
print(l+r)
N,K = (int(X) for X in input().split())
A  = [int(X) for X in input().split()]
OI = A.index(1)
L = (OI+(K-2))//(K-1)
R = ((N-OI-1)+(K-2))//(K-1)
print(L+R)
n, k = map(int,input().split())
input()
print((n - 1)//(k-1) + 1)
n, k = map(int, input().split())
print((n + k - 2) // (k - 1))
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
print(l,r)
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())
nums = [int(i) for i in input().split()]


def calc(n, k):
    cnt = 0
    while True:
        tmp = n // 3
        n = tmp + n % 3
        cnt += tmp
        if n <= K:
            cnt += 1
            return cnt


if len(nums) <= K:
    print(1)
else:
    print(calc(N, K))
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
if N == K:
    print(1)
else:
    ans = ceil(N/(K-1))
    print(ans)
# 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 and i >= (N - K):
    print(2)
    exit()
elif i < K:
    i = K
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())
print((n-1+k-1)//(k-1))
def Minimization(n , k , al):

    ans = -(-n // k)

    return ans

def main():
    n , k = map(int , input().split())
    al = list(map(int , input().split()))
    print(Minimization(n , k , al))

if __name__ == '__main__':
    main()
N, K = list(map(int, input().split()))
numlist = list(map(int, input().split()))


print(N // (K - 1))
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
if N == K:
    print(1)
elif N == (K-1)*2 + 1:
    print(2)
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()))

if n == k:
    print(1)
else:
    print(n // (k-1))
n,k,*_=map(int,open(0).read().split())
print(-~n//-~k)
def main():
    n, k = map(int, input().split())
    a_lst = list(map(int, input().split()))
    min_index = a_lst.index(1)

    before = 0
    tmp1 = 0
    while tmp1 < min_index:
        before += 1
        tmp1 = (k - 1) * before

    after = 0
    tmp2 = 0
    while tmp2 < n - 1 - min_index:
        after += 1
        tmp2 = (k - 1) * after

    answer = before + after
    print(answer)


if __name__ == '__main__':
    main()
# coding: utf-8
# Your code here!
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
m=A.index(1)
ans=0
l=m
#print(l)
if N==K:
    print(1)
else:
    while l>0:
        ans+=1
        l-=(K-1)
    l=m
    while l<N-1:
        ans+=1
        l+=(K-1)
    print(ans)
import numpy as np
N,K= map(int,input().split())
A = list(map(int,input().split()))
mi=np.argmin(A)
mi2=np.argmin(A)
s=0
while True:
  if mi>0:
    mi=mi-K+1
    s=s+1
    #print(s,mi)
  else:
    break
while True:
  if mi2<N-1:
    mi2=mi2+K-1
    s=s+1
    #print(s,mi2)
  else:
    break
print(s)
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N==K:
    print(1)
    exit(0)
index = A.index(1)

ans = (N-1-index+K-2)//(K-1) + (index+K-2)//(K-1)

print(ans)
import math

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    i = A.index(1)
    before = len(A[:i])
    after = len(A[i+1:])
    
    return math.ceil(before / (M - 1)) + math.ceil(after / (M - 1))

print(solve())
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans = 1
N -= K
while N<=0:
  ans += 1
  N -= K-1
print(ans)
n, k = map(int, input().split())
print(n // (k-1))
N,K = map(int,input().split())
li = [int(i) for i in input().split()]

min_index = li.index(1)
left = min_index
right = len(li) - left - 1
# print("left", left, "right", right)

count = 0

if (N == K) :
    count = 1
else :
    if (left > 0) :
        count += left // (K-1)
        if (left % (K-1) != 0) :
            count += 1

    if (right > 0) :
        count += right // (K-1)
        if (right % (K-1) != 0) :
            count += 1

print(count)
N, K = list(map(int, input().split()))
numlist = list(map(int, input().split()))
listlengh = len(numlist)
minpos = numlist.index(1) + 1
front = (listlengh - minpos) + 1


print(front // (K - 1 ) + minpos // (K - 1))