peterverebics/CodeNet_Python_118 huggingface dataset:
N, K = map(int,input().split())
AN = list(map(int,input().split()))
AN.sort()
N = N - AN.count(AN[0])

print( -(-N//(K-1)) )
from math import ceil

N, K = map(int, input().split())
A = list(map(int, input().split()))
print(ceil((N - 1) / (K - 1)))
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, k, *a = map(int, readline().split())

ans = math.ceil((n-1)/(k-1))
print(ans)
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=math.ceil((n-1)/(k-1))
print(ans)
import math
N, K = map(int, input().split())
print(math.ceil((N-1) /(K-1)))
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

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

# 求解処理
ans = math.ceil((N - 1) / (K - 1))

# 結果出力
print(ans)
n,k=map(int,input().split())
a=list(map(int,input().split()))
num=min(a)
if a[0]==num:
    n-=1
if a[-1]==num:
    n-=1
n-=1
k-=1
print(-1*(n//-k))
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()

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

    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())
a=sorted(list(map(int,input().split())))

if (n-k)%(k-1)==0: print(1+(n-k)//(k-1))
else: print(1+(n-k)//(k-1)+1)
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
print(count)
import math

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

s.sort()
s.remove(s[0])

ans = math.ceil(len(s)/(k-1))
print(ans)
n,k=map(int,input().split())
a=list(map(int,input().split()))
if (n-1)%(k-1)==0:
    print((n-1)//(k-1))
else:
    print((n-1)//(k-1)+1)
from math import ceil
a,b = map(int,input().split())
c = input()
print(ceil((a-1)/(b-1)))
N,K = map(int,input().split())
A = list(map(int,input().split()))

count =0
first = True
while N >=K:
    if  first ==True:
        count +=1
        N-=K
        first =False
        
    else:
        count+=1
        N-=(K-1)
        
   
    

if N!=0:
    count+=1
print(count)
n,k=map(int,input().split())
print((n+k-3)//(k-1))
import math
def main():
    n,k = map(int, input().split())
    A = list(map(int, input().split()))

    print(math.ceil((n-1)/(k-1)))


if __name__ == '__main__':
    main()
#!/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()
print((n-2)//(k-1)+1)
import math
n,k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

print(math.ceil((n-1)/(k-1)))
import math


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

    
if __name__ == '__main__':
    main()
N,K = map(int,input().split())
A = list(map(int,input().split()))
count = 0
while N > 1:
  N -= K - 1
  count += 1
print(count)
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))

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

if k < n:
    c = 1
    n -= k
    c += -((-n)//(k-1))
    print(c)
else:
    print(1)
import math

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

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

print(math.ceil((n-1)/(k-1)))
import math,sys

N, K = map(int, input().split())
window = K - 1
A = list(map(int, input().split()))
# mi_index = A.index(min(A))
# left_count = math.ceil(mi_index / (K - 1))
# right_count = math.ceil((N - (mi_index + 1)) / (K - 1))
# left = mi_index
# right = mi_index
# while left > 0 or right < N-1:
#   if left >= 0 and left > window:
#     left -= window
#   elif N - 1 - right >= window:
#     right += window
  
#   print(left, right)


l = K
count = 1
if l >= N:
  print(count)
  sys.exit()
  
while l < N:
  l += K - 1
  count += 1

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

print((n-2)//(k-1)+1)
import math

def Minimization(n , k , al):

    ans = math.ceil((n - 1) / (k - 1))

    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()
import math
N,K = map(int,input().split())
L = [i for i in map(int,input().split())]
#if (N-1) % (K-1) != 0:
  #print(((N-1)//(K-1))+1)
#else:
  #print((N-1) % (K-1)) #equivalent to ceil.
print(math.ceil((N-1)/(K-1)))
n, k = map(int, input().split());print(1 + (n - k) // (k - 1) + ((n - k) % (k - 1) != 0))
n,k=map(int,input().split())
print((n-1)//(k-1)+((n-1)%(k-1)!=0))
n,k=map(int,input().split())
a=list(map(int,input().split()))

import math
print( math.ceil( (n-1)/(k-1) ) )
def main():
    n, k, *a = map(int, open(0).read().split())
    ans = 1 + (n - k) // (k - 1) + ((n - k) % (k - 1) != 0)
    print(ans)


if __name__ == '__main__':
    main()
n, k = map(int, input().split())
a = list(map(int, input().split()))
idx = a.index(1)
if idx == 0:
    print(-(-len(a[(idx + 1):]) // (k - 1)))
elif idx == (n - 1):
    print(-(-len(a[:idx]) // (k - 1)))
else:
    print(-(-(n - 1) // (k - 1)))
import sys
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
print(math.ceil((N-1)/(K-1)))
n,k = map(int,input().split())
if (n-k)%(k-1) == 0:
  print((n-k)//(k-1)+1)
else:
  print((n-k)//(k-1)+2)
import math
n, k = map(int, input().split())
a = [int(_) for _ in input().split()]
print(math.ceil((n-1) / (k-1)))
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N,K=map(int,input().split())
print(-(-(N-1)//(K-1)))
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = math.ceil((n-1)/(k-1))
print(ans)
N, K = map(int, input().split())
A = list(map(int, input().split()))
eq = 1
cnt = int()
while eq<N:
    eq += (K-1)
    #print(cnt, eq)
    cnt +=1

print(cnt)
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

print(math.ceil((N-1)/(K-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()))
    print(math.ceil((N-1)/(K-1)))


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

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

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

a = list(map(int, input().split()))
n -= 1
k -= 1
ans = math.ceil(n / k)

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

argmin = A.index(1)

back = (argmin+(K-1)-1)//(K-1)
forward = (N-argmin-1+(K-1)-1)//(K-1)
ans1 = back+forward

ans2 = ((N-1)+(K-1)-1)//(K-1)

print(min(ans1,ans2))
# -*- 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))
if x % (K - 1) != 0:
    y -= K - 1 - (x % (K - 1))
ans += math.ceil(y / (K - 1))

# 結果出力
print(ans)
from math import ceil
n,k=map(int,input().split())
a=list(map(int,input().split()))

print(ceil((n-1)/(k-1)))
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=len(a)
ans-=k
if ans%(k-1)==0:
  print(ans//(k-1)+1)
else:
  print(ans//(k-1)+2)
N,K = map(int,input().split())
A = list(map(int,input().split()))
print((len(A)-1)//(K-1) + int(bool((len(A)-1)%(K-1))))
n,k = map(int,input().split())
import math
print(math.ceil((n-1)/(k-1)))
N,K = list(map(int,input().split()))
n=(N-K)//(K-1)+1
mod=(N-K)%(K-1)
if mod!=0:
    n+=1

print(n)
n, k = map(int, input().split())
input()
print((n-2)//(k-1) + 1)
import math

def main():
    n, k = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]

    ans = math.ceil((n - 1)/(k - 1))
    print(ans)

if __name__ == "__main__":
    main()
import math

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

n = max(0, N - K)
print(1 + math.ceil(n / (K - 1)))
n,k = map(int,input().split())
print((n+k-3) // (k-1))
N,K=map(int,input().split())
if (N-1)%(K-1)==0:
  print((N-1)//(K-1))
else:
  print((N-1)//(K-1)+1)
n,k = map(int,input().split())
a = list(map(int,input().split()))
print((n-2)//(k-1)+1)
import math
n,k = map(int,input().split())
print(math.ceil((n-1)/(k-1)))
n,k=map(int,input().split())
cnt=1
n-=k
cnt+=(n+k-2)//(k-1)
print(cnt)
import math

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


print(math.ceil((N-1)/(K-1)))
n,k=map(int,input().split())
*a,=map(int,input().split())
print((n-2)//(k-1)+1)
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = k
count = 1
while ans < n:
    ans += k-1
    count += 1
print(count)
from math import ceil
n,k = map(int,input().split(" "))


print(ceil((n - 1) / (k - 1)))
[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))

if (N-1)%(K-1)==0:
    out=(N-1)//(K-1)
else:
    out=(N-1)//(K-1)+1

print(out)
N,K=map(int,input().split())

a=(N-1)%(K-1)
b=(N-1)//(K-1)

if a==0:
  print(b)
else:
  print(b+1)
N, K = map(int, input().split())
if (N - 1) % (K - 1) == 0:
    print((N-1)//(K-1))
else:
    print((N-1)//(K-1)+1)
n=input().rstrip().split()
preans=(int(n[0])-1)/(int(n[1])-1)
 
ans=int(preans)
if (int(n[0])-1)%(int(n[1])-1)!=0:
  ans+=1
print(ans)
#!usr/bin/env python3
import math
N, K = map(int, input().split())    

print(math.ceil((N-1)/(K-1)))
import math
N, K = list(map(lambda k: int(k), input().split(" ")))
A = list(map(lambda a: int(a), input().split(" ")))

print(math.ceil((N - K) / (K - 1)) + 1)
n,k=list(map(int, input().split()))
a= list(map(int, input().split()))
final=min(a)
ans=0
flag=-1
check=0
for v in a:
    if flag==-1 and v!=final:
        flag=2
        ans+=1
        check=0
        if flag==k:
            flag=-1
    elif flag>=0:
        if check==0 and v==final:
            flag-=1
            check=1
        flag+=1
        if flag==k:
            flag=-1
print(ans)
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
if n<=k:
  print(1)
  exit()
n=n-k
if n%(k-1)==0:
  print(1+n//(k-1))
else:
  print(1+n//(k-1)+1)
n, k  = [int(i) for i in input().split()]
nums = [int(i) for i in input().split()]

count = 0

while n > 0:
    if n > k:
        n -= k-1
    else:
        n -= k
    count += 1

print(count)
import math
N,K = map(int,input().split())
lsA = list(map(int,input().split()))
print(math.ceil((N-1)/(K-1)))
n,k=map(int,input().split())
print(-(-(n-1)//(k-1)))
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans=0
while 1:
  if N>K:
    N -= (K-1)
    ans+=1
  else:
    ans+=1
    break
print(ans)
from math import ceil
n,k=map(int,input().split())
ans=1
n-=k
print(ans+ceil(n/(k-1)))
n, k = map(int, input().split())
a = list(map(int, input().split()))
count = 1
n = n-k
while n > 0:
    n -= k-1
    count += 1
print(count)
import math
n,k=map(int,input().split())
input()
print(math.ceil((n-1)/(k-1)))
import math
n, k = map(int, input().split())
a = [int(i) for i in input().split()]


print(int(math.ceil((len(a)-1) / ( k -1))))
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A.index(min(A))
r=a
l=N-(r+1)
rc=r//(K-1)
lc=l//(K-1)

if N-(rc+lc)*(K-1)==1:
  print(rc+lc)
elif 1<N-(rc+lc)*(K-1)<=K:
  print(rc+lc+1)
else:
  print(rc+lc+2)
n, k = map(int,input().split())
print((n-1+k-2)//(k-1))
import math
n,k = map(int,input().split())
s = input()
#print(n-1,k-1)
print(math.ceil((n-1)/(k-1)))
from math import ceil

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

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

if n == k:
    print(1)
    exit()
import math
print(1 + math.ceil(((n - k) / (k-1))))
import math
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
print(math.ceil((n - k) / (k - 1)) + 1)
from math import ceil
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
n=n-k
c=1
if(n>0):
    c+=ceil(n/(k-1))
print(c)
import math 

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

a = list(map(int, input().split()))
g = 1 
i = 0
while g < n:
    g += (k -1)

    i += 1
print(i)
def main():
  n, k = map(int, input().split())
  if (n - k) % (k - 1):
    print(1 + (n - k) // (k - 1) + 1)
  else:
    print(1 + (n - k) // (k - 1) )
if __name__=="__main__":
  main()
import math

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

print(math.ceil((n - 1) / (k - 1)))
n,k=map(int,input().split())
if n==k:
  print(1)
elif k==2:
  print(n-1)
elif n%(k-1)==1:
  print(n//(k-1))
else:
  print((n+k-2)//(k-1))
import math
n, k = map(int,input().split())
a = list(map(int,input().split()))
print(math.ceil((n-1)/(k-1)))
n,k=map(int,input().split())
a=list(map(int,input().split()))
print(((n-2)//(k-1))+1)
N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
A.pop(1)
f=len(A)//(K-1)
if len(A)%(K-1)==0:
    print(f)
else:
    print(f+1)
n, k = map(int, input().split())
a = list(map(int, input().split()))

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

N, K = map(int, input().split())
A = [int(i) for i in input().split()]
print(math.ceil((N-1)/(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(True):
    n-=k
    ans+=1
    if n<=0:
      break
    else:
      n+=1
      
  print(ans)
N,K = map(int,input().split())

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

cnt = 1

ans = K

while ans < N:
    cnt += 1
    ans += K-1

print(cnt)
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = n - k
c = 0
if ans > 0:
    c = math.ceil(ans / (k-1))

print(c+1)
[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))

N = N-K
if N%(K-1)==0:
    print(N//(K-1)+1)
else:
    print(N//(K-1)+1+1)
N, K = map(int, input().split())
ans = 1 + ((N - K) + (K - 2)) // (K - 1)
print(ans)
n, k = list(map(int, input().split()))
a = input()
ans = []
left = a.index('1')
right = n -left -1
for i in range(k):
    l = left-i
    r = right-k+1+i
    if l==0:
        ans.append(right//k+1)
    else:
        ans.append((l-1)//(k-1)+1+1+(r-1)//(k-1)+1)
print(min(ans))
N,K = map(int,input().split())
A = list(map(int,input().split()))

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

i=A.index(1)+1
if i<=K or i>=N-K:
    ans=(N-K)//(K-1)+1 if (N-K)%(K-1)==0 else (N-K)//(K-1)+2
else:
    for a in range(K):
        if (i-a)%(K-1)==0 and (N-(i+(K-a)))%(K-1)==0:
            b=0
        else:
            b=1
    front=i//(K-1)
    back=(N-(i+K))//(K-1)
    ans=front+back+1+b
print(ans)
from math import ceil
n,k=map(int,input().split())
A=list(map(int,input().split()))
print(ceil((n-1)/(k-1)))
N,K = map(int,input().split())
A = list(map(int,input().split()))
x = (N-1)//(K-1)
if (N-1)%(K-1) != 0:
    x += 1
print(x)
import sys

import bisect

# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd

import itertools

# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int, readline().split()))
    a = list(map(int, readline().split()))

    ans = 1
    rem = max(n - k, 0)
    ans += math.ceil(rem / (k - 1))

    print(ans)


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

m = a.index(1)
print(ceil((n-1)/(k-1)))
N,K = map(int,input().split())
A = list(map(int,input().split()))
count = 0
i = 1

for _ in range(N):
  i = i + K - 1
  if i < N:
    count += 1

  else:
    count += 1
    break

print(count)
N,K=map(int,input().split())
List = list(map(int, input().split()))
k=K-1
n = (N-1)/k
nn = int(n)
if n-nn > 0:
  nn = nn+1
print(nn)
n, k = map(int, input().split())
A = tuple(map(int, input().split()))
count = -(-(n - 1) // (k-1))
print(count)
def main():
    N, K = map(int, input().split())
    A = input()
    if N == K:
        print('1')
    elif (N-1) % (K-1) == 0:
        print((N-1)//(K-1))
    else:
        print((N-1)//(K-1) + 1)
main()
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

print(-((1 - N) // (K - 1)))
def read_input():
    n, k = map(int, input().split())
    alist = map(int, input().split())

    return n, k, alist


def submit():
    n, k, alist = read_input()

    if k >= n:
        print(1)
        return

    n = n - k
    if n % (k - 1):
        print(n // (k - 1) + 2)
    else:
        print(n // (k - 1) + 1)


if __name__ == "__main__":
    submit()
import math

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


indx = a.index(min(a))
i = (indx-1) + (n-indx)

if i % (k-1) == 0:
    print(int(i/(k-1)))
else:
    print(int(i/(k-1))+1)
from math import ceil
n,k = map(int, input().split())
a = list(map(int, input().split()))

m = a.index(1)
print(ceil(m/(k-1)) + ceil((n-1-m)/(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 - b
if K < b:
    a -= K - a
    
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
def resolve():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	i = a.index(min(a))
	v = math.ceil(i/(k-1)) + math.ceil((n-1-i)/(k-1))
	print(v)
resolve()
N,K = map(int,input().split())
print(N//(K-1))
N, K = map(int, input().split())
A = list(map(int, input().split()))

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

if N == K:
    y = 0
else:
    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 numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

mi = A.index(1)
lc = math.ceil(mi/2)
rc = math.ceil((N-mi-1)/2)

print(lc+rc)
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

i = a.index(1)

s = n

for j in range(i-k+1, i+k):
    if j < 0:
        continue
    elif j >= n:
        continue
    else:
        l = j
        u = (n-1-j)
        t = (l+1) // (k-1) + (u+1) // (k-1)
        #print(t)
        s = min(s, t)

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

b = a.index(1) 
if b < k-1:
    b += k-1 -b
if b > (n-1) -(k-1):
    b -= b - (k-1)
c,d = divmod(b,k-1)
ans = c
if d != 0:
    ans +=1
e = n-1 -b
c,d = divmod(e,k-1)
ans += c
if d != 0:
    ans +=1
print(ans)
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
mn = min(left_length,right_length)
mx = max(left_length,right_length)

mx -= mn % (k-1)

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

mx -= mn % (k-1)

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




print(counter)
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

mi = A.index(1)
lc = math.ceil(mi//2)
rc = math.ceil((N-mi-1)//2)

print(lc+rc)
n, k = map(int, input().split())
a = list(map(int, input().split()))


fi = 0
for i in range(n):
    if a[i] == 1:
        fi = i
        break

print((n - fi) // (k - 1) + fi // (k - 1))
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
b = a.index(1)
c,d = divmod(b,k-1)
ans = c
if d != 0:
    ans +=1
e = n-1 -b
c,d = divmod(e,k-1)
ans += c
if d != 0:
    ans +=1
print(ans)
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 10**10
    for k in range(K):
        v = 0
        if k > 0:
            v += 1
        v += (N - k) // (K - 1)
        if (N - k) % K > 1:
            v += 1
        if v < ans:
            ans = v
    print(ans)


if __name__ == '__main__':
    main()
n, k  = [int(i) for i in input().split()]
nums = [int(i) for i in input().split()]

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

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

print(cnt)
x, y = map(int,input().split())
li = list(map(int,input().split()))

a = li.index(1) #1より前にある数
b = x-1-a #1より後にある数

if a%(y-1) == 0 and b%(y-1) == 0:
    print(a//(y-1)+b//(y-1))
elif a%(y-1) == 0 or b%(y-1) == 0:
    print(a//(y-1)+b//(y-1)+1)
else:
    print(a//(y-1)+b//(y-1)+2)
from math import ceil, floor

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

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

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

cnt = 0
if idx + 1 == K:
    cnt += 1
else:
    cnt += ceil((idx + 1) / (K - 1))

if N - idx == K:
    cnt += 1
else:
    cnt += ceil((N - idx) / (K - 1))

print(cnt)
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.ceil(i/(K-1)) + math.ceil((N-i-1)/(K-1)))
        break
N, K = map(int, input().split())
A = list(map(int, input().split()))

if N % (K-1) == 0:
    ans = N // (K-1)
else:
    ans = (N // (K-1)) + 1
    if N == K:
        ans -= 1

print(ans)