Problem:
 Score : 300 points    Problem Statement There is a sequence of length N : A_1, A_2, ..., A_N . Initially, this sequence is a permutation of 1, 2, ..., N .  On this sequence, Snuke can perform the following operation:   Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.   Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.
Find the minimum number of operations required.
It can be proved that, Under the constraints of this problem, this objective is always achievable.      Constraints  2 \leq K \leq N \leq 100000  A_1, A_2, ..., A_N is a permutation of 1, 2, ..., N .         Input Input is given from Standard Input in the following format:  N  K  A_1  A_2  ...  A_N       Output Print the minimum number of operations required.        Sample Input 1 4 3
2 3 1 4      Sample Output 1 2  One optimal strategy is as follows:    In the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4 .    In the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1 .         Sample Input 2 3 3
1 2 3      Sample Output 2 1       Sample Input 3 8 3
7 3 1 8 4 6 2 5      Sample Output 3 4

Solution (Python):
""" AtCoder """

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

p = K
ans = 1

while True:
    if p >= N:
        break
    p += K - 1
    ans += 1

print(ans)

Solution (Python):
N, K = map(int, input().split())
_ = input()
print((N-1)//(K-1) + ((N-1)%(K-1) > 0))

Solution (Python):
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
print(math.ceil((N-1)/(K-1)))

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    A = [int(input_raw[i]) for i in range(N)]
    for i in range(N):
        if A[i] == 1:
            break
    one_idx = i
    min_count = sys.maxint
    for i in range(K):
        left_num = max(0, one_idx - i)
        right_num = max(0, N - (one_idx + K - i))
        x_left = 0
        if left_num > 0:
            x_left = max(1, (left_num))/ (K - 1) + (1 if max(0, (left_num)) % (K - 1) != 0 else 0)
        x_right = 0
        if right_num > 0:
            x_right = max(1, (right_num))/ (K - 1) + (1 if max(0, (right_num)) % (K - 1) != 0 else 0)
        min_count = min(x_left + x_right, min_count)

    print min_count + 1

if __name__ == '__main__':
    main()

Solution (Python):
a, b = map(int, input().split())
print(-(-(a-1)//(b-1)))

Solution (Python):
n,k=map(int,input().split())
li=list(map(int,input().split()))
b=n-k
if n==k:
    print(1)
elif b%(k-1)==0:
    print(1+(b//(k-1)))
else:
    print(2+(b//(k-1)))

Solution (Python):
import math 
n, k = map(int, input().split())
print(math.ceil((n - 1) / (k - 1)))

Solution (Python):
import math
n,k=map(int,input().split())
A=list(map(int,input().split()))
print(1 if n-k==0 else math.ceil((n-1)/(k-1)))

Solution (Python):
import math
n,k=map(int,input().split())
A=list(map(int,input().split()))
print(1 if n-k==0 else math.ceil((n-1)/(k-1)))

Solution (Python):
from sys import stdin
n, k = [int(x) for x in stdin.readline().rstrip().split()]
if (n-1) % (k-1) == 0:
    print(int((n-1)/(k-1)))
else:
    print(divmod((n-1), (k-1))[0]+1)

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

onep=A.index(1)
ans=100000000000
def solve(l,r):
    global A,N,K
    ans=0

    while(l>0):
        
        l-=(K-1)
        ans+=1

    while(r<len(A)-1):
        r+=(K-1)
        ans+=1
    return ans

for i in range(-(K-1),1):
    ans=min(ans,solve(onep+i,onep+(K-1+i))+1)

print(ans)

Solution (Python):
from math import ceil

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

if n <= k:
    print(1)
    exit()
res = 0

range_left = array.index(1)
range_right = n - range_left - 1

k -= 1
if range_left == 0:
    res += ceil(range_right / k)
    print(res)
    exit()
elif range_right == 0:
    res += ceil(range_left / k)
    print(res)
    exit()

if range_left <= k:
    res += 1
    range_right -= (k - range_left)
    res += ceil(range_right / k)
else:
    res += ceil(range_left / k)
    tmp = 0
    while tmp < range_left:
        tmp += k
    range_right -= tmp % range_left
    res += ceil(range_right / k)
print(res)

Solution (Python):
n,k=map(int,input().split());print((n+k-3)//~-k)

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
print((n-k-1)//(k-1)+2)

Solution (Python):
n,k = map(int,input().split())
l = list(map(int,input().split()))

a = l.index(min(l))
b = a

p = n//2
count = 0
if p>a:
    while b>0:
        b -= k-1
        count += 1

    while a<n-1+b:
        a += k-1
        count += 1

else:
    while a<n-1:
        a += k-1
        count += 1

    while b>a-n+1:
        b -= k-1
        count += 1

print(count)

Solution (Python):



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

ind = -1
for i in range(1, N+1):
    if A[i] == 1:
        ind = i

hoge = ind - 1

ans = 0
ans += hoge // (K-1)

fuga = hoge % (K-1)
if fuga > 0:
    ans += 1
    ind += (K-1) - fuga

ans += max(0, (N - ind) // (K-1) + (1 if (N-ind) % (K-1) else 0))
print(ans)

Solution (Python):



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

h = map(int, raw_input().split())


print (n + k - 3) / (k - 1)

Solution (Python):
import math 
n, k = map(int, input().split())
print(math.ceil((n - 1) / (k - 1)) )

Solution (Python):
N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

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

Solution (Python):
def inpl(): return [int(i) for i in input().split()]
N, K = inpl()
print(-(-(N-1)//(K-1)))

Solution (Python):
N,K=map(int,input().strip().split(' '))
a=list(map(int, input().split()))










ans=-(-(N-1)//(K-1))
print(ans)

Solution (Python):
n, k = map(int, input().split())
print((n - 2) // (k - 1) + 1)

Solution (Python):
import math
N, K = map(int, input().split())
print(math.ceil((N - 1)/ (K - 1)))

Solution (Python):
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
mini = min(A)
i = 0
cnt = 0
f = False
while(i < N - 1):
    if f and A[i + 1] == mini:
        i += 1
        continue
    if not f and min(A[i:min(N, i + K)]) == mini:
        f = True
    i += K - 1
    cnt += 1
print(cnt)

Solution (Python):
import math as m
N,K = map(int,input().split())
A = list(map(int,input().split()))
order_1 = A.index(1) + 1
l = []
if order_1 <= K or order_1 >= N-K+1:
  print(m.ceil((N - K)/(K - 1)) + 1)
else:
  for i in range(K):
    count_r = m.ceil((N - order_1 - i)/(K - 1))
    count_l = m.ceil((order_1 + i - K)/(K - 1))
    count_total = count_r + count_l + 1
    l.append(count_total)
  print(min(l))

Solution (Python):
import math

def main():
    n,k = [int(i) for i in input().split()]
    a = [int(i) for i in input().split()]
    ans = math.ceil((n-1)/(k-1))
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

oneIdx = 0
for i, a in enumerate(A):
    if 1 == a:
        oneIdx = i

count = 0

i = oneIdx
while (i <= N-2):
    i += (K-1)
    count += 1

i = oneIdx
while (i >= 1):
    i -= (K-1)
    count += 1



i = 0
count2 = 0
while (i <= N - 2):
    i += (K - 1)
    count2 += 1


if N == 1:
    print(0)
elif N <= K:
    print(1)
else:
    print(min(count, count2))

Solution (Python):
N,K = map(int,input().split())
A = list(map(int,input().split()))
S = len(A) - 1
K -= 1;
ans = S//K
if S%K : ans+=1
print(ans)

Solution (Python):
N, K = map(int, input().split(" "))
print((N - K)//(K-1)+1 + ((N-K)%(K-1)>= 1)*1)

Solution (Python):
import math

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

i = A.index(1)

print(math.ceil((N - 1) / (K - 1)))

Solution (Python):
N, K = list(map(int, input().split()))
n = N - 1
k = K - 1
if n % k == 0:
	print(int(n // k))
else:
	print(int(n // k) + 1)

Solution (Python):
N,K = map(int,input().split())
ai = list(map(int,input().split()))
ans = (N-1)//(K-1)
if (N-1)%(K-1)>0:
    ans += 1
print(ans)

Solution (Python):
n, m = map(int, input().split(' '))
print((n + m - 3) // (m - 1))

Solution (Python):
import math;a,b=map(int,input().split());print(math.ceil((a-1)/(b-1)))

Solution (Python):
n,k = map(int, input().split())
if (n-1)%(k-1) == 0:
    print(int((n-1)/(k-1)))
else:
    print(int((n-1)//(k-1) + 1))

Solution (Python):
N, K = map(int, input().split())
input()
print(1 - (-(N - K) // (K - 1)))

Solution (Python):
n,m=map(int,input().split());print((n+m-3)//(m-1))

Solution (Python):
n,k = map(int,input().split())	
a = list(map(int,input().split()))
ans = []

w = a.index(1)
if w%(k-1) ==0:
    x = w//(k-1)
else:
    x = w//(k-1) + 1

if (n-w-1)%(k-1) == 0:
    y = (n-w-1)//(k-1)
else:
    y = (n-w-1)//(k-1) + 1
ans.append(x+y)

for i in range(k):
    r = w-i
    if r%(k-1) ==0:
        x = r//(k-1)
    else:
        x = r//(k-1) + 1
    
    p = w+k-1-i
    if (n-p-1)%(k-1) == 0:
        y = (n-p-1)//(k-1)
    else:
        y = (n-p-1)//(k-1) + 1
    ans.append(x+y+1)

print(min(ans))

Solution (Python):
import math
N,K = map(int,input().split())
print(int(math.ceil((N-1)/(K-1))))

Solution (Python):

from math import ceil
n,k = map(int, input().split())
a = input()
print(ceil((n-1)/(k-1)))

Solution (Python):

import math
s=input().split()
n,k=int(s[0]),int(s[1])
print(math.ceil((n-1)/(k-1)))

Solution (Python):
import math
n,k = list(map(int,input().split()))
print(math.ceil((n-1)/(k-1)))

Solution (Python):
import math
n,k = list(map(int,input().split()))
k -= 1
print(math.ceil((n-1)/k))

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

Solution (Python):
n,k = map(int,input().split()); print(-(-(n-1)//(k-1)))

Solution (Python):
n, k = [int(i) for i in input().strip().split(' ')]
As = [int(i) for i in input().strip().split(' ')]
for i, a in enumerate(As):
    if a == 1:
        x = i+1

lm = (x-1) % (k-1)
rm = (n - x) % (k-1)
if lm == 0 and rm == 0:
    print(int((x - 1) / (k-1))+int((n - x) / (k-1)))
elif lm == 0 or rm == 0:
    print(int((x - 1) / (k-1))+int((n - x) / (k-1)) + 1)
else:
    if lm + rm <= k-1:
        print(int((x - 1) / (k-1))+int((n - x) / (k-1)) + 1)
    else:
        print(int((x - 1) / (k-1))+int((n - x) / (k-1)) + 2)

Solution (Python):

import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
min_a = min(a)
ans = 0
l = 0
while l < n:
    if a[l] == min_a:
        l += 1
    else:
        if min_a in a[l : l + k - 1]:
            l += k
        else:
            l += k - 1
        ans += 1
print(ans)

Solution (Python):
import numpy as np
from math import ceil

N, K = tuple(map(int, input().split()))
A = np.array([int(x) for x in input().split()])

I = np.argmin(A)
D = max(1, min(N - I, I) - 1)
C = K - 1
small_part = ceil(D / C)
done = C * small_part + 1

print(small_part + ceil((N - done) / C))

Solution (Python):
def main():
  t = input().split(" ")
  N, K = int(t[0]), int(t[1])
  
  t = input()
  
  a = (N-2) // (K-1) + 1
  print(a)

main()

Solution (Python):
import math
n, k = map(int, input().split())
print(math.ceil((n - 1) / (k - 1)))

Solution (Python):
import sys

l1 = sys.stdin.readline().strip().split()
l2 = sys.stdin.readline().strip().split()
l1 = [int(x.strip()) for x in l1]
l2 = [int(x.strip()) for x in l2]


N = l1[0]
k = l1[1]
A = l2

p = A.index(1)

nl = [0,0]
nr = [0,0]

def culc(q):
	m = 0
	l = 0
	if k >= q:
		m = 0
	else:
		m = (q-1) // (k-1)
	if m == 0:
		l = 0 
	else:
		l = (k-1)*(m-1) + k-1 
	return [m, l]

nl = culc(p)
nr = culc(N-1-p)


nr[1] = N-1-nr[1]



if nl[1] + (k-1) >= nr[1]:
	c = nl[0] + nr[0] + 1
else:
	c = nl[0] + nr[0] + 2

print(c)

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


import math


ans = math.ceil((N-K) / (K - 1)) + 1
print(ans)

Solution (Python):
def getinputdata():

    
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
k = int(arr_data[0][1])

arr = [int(x) for x in arr_data[1]]

cnt=1
if n <= k:
    
    print(cnt)
    
else:
    
    chkflg = True
    
    while chkflg:
        
        cnt+=1

        s = k + 1 + (k-1) * (cnt-2)
        e = k * 2-1 + (k-1) * (cnt-2)
        
        if s<=n<=e:
            
            chkflg=False
            
            
    print(cnt)

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



ans = -(-(n-1)//(k-1))

print(ans)

Solution (Python):
from bisect import *

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, K = reads()

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

Solution (Python):

N,K = map(int,raw_input().split())
A = map(int, raw_input().split())

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

Solution (Python):


NK = list(map(int, input().split()))
A = list(map(int, input().split()))

N,K = NK[0],NK[1]

wb = True
counter = 0


while wb:
    if counter == 0:
        N = N - K
    else:
        N = N - (K - 1)
    counter+=1
    if N <= 0:
        wb = False

print(counter)

Solution (Python):
import math
n, k = [int(i) for i in input().split()]
A = [int(i) for i in input().split(" ")]

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

Solution (Python):
import math

if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    
    input()
    ans = math.ceil((N-1) / (K-1))
    print(ans)

Solution (Python):
n,k=map(int,input().split())
print((n-2)//(k-1)+1)

Solution (Python):
n, k = map(int, input().split())
print((n - 2) // (k - 1) + 1)

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))
n = 0
i = 0
first = True
while True:
    if first:
        n += K
    else:
        n += K - 1
    first = False
    i += 1
    if n >= N:
        break
print(i)

Solution (Python):
n,k = map(int,input().split())
print( ( (n-1 + k-2)//(k-1) ) )

Solution (Python):
n, k = map(int, raw_input().split())
print (n + k - 3) / (k - 1)

Solution (Python):
import math
N, K = list(map(int, input().split()))
print(math.ceil((N-1)/(K-1)))

Solution (Python):
import math
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

assert isinstance(A,list)
a = A.index(1)

print(math.ceil((N-1)/(K-1)))

Solution (Python):
import sys

n, k = map(int, sys.stdin.readline().split())

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

Solution (Python):
import sys, math

n, k = map(int, sys.stdin.readline().split())

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

Solution (Python):
n, k = map(int, input().split())
print((n - 2) // (k - 1) + 1)

Solution (Python):
n,k=map(int,input().split(' '))
print((n+k-3)//(k-1))

Solution (Python):
I=raw_input()
IL=I.split()
n=int(IL[0])
k=int(IL[1])
I2=raw_input()
x=(n-1)/(k-1)
if(x*(k-1)!=(n-1)):
   x+=1
print x

Solution (Python):
n, k = map(int, input().split())
n -= 1
k -= 1
print((n+k-1)//k)

Solution (Python):
from math import ceil

N, K = [int(w) for w in input().split()]
A    = [int(w) for w in input().split()]
if len(A) != N: raise

print(ceil((N - 1) / (K - 1)))

Solution (Python):
N,K=map(int,input().split())
width=K
answer=1

while(True):
 if width>=N:
  break;
 width+=K-1
 answer+=1

print(answer)

Solution (Python):
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = n
for i in range(0,k-1):
    ans = min((math.ceil((n-1-i)/(k-1)) + math.ceil(i/(k-1))),ans)
print(ans)

Solution (Python):
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
print (N-2)/(K-1)+1

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))
i = a.index(min(a))
def solve(x, y):
    q1 = (x+k-2)//(k-1)
    r = ((k-1)-x%(k-1))%(k-1)
    q2 = max(0, y+k-2-r)//(k-1)
    return q1+q2
x = i
y = n-i-1
print(min(solve(x, y), solve(y, x)))

Solution (Python):
N, K = map(int, input().split())
*A, = map(int, input().split())

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

Solution (Python):
N, K = map(int,input().split())
print((N-2)//(K-1)+1)

Solution (Python):

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

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

Solution (Python):
from math import ceil

N, K = map(int, input().split())
A = [int(_) for _ in input().split()]
front = A.index(1)
back = N - front - 1

ret = 10000000
for i in range(K):
    ff = front - i
    bb = back - (K - 1 - i)
    if ff >= 0 and bb >= 0:
        ret = min(ret, 1 + ceil(ff/(K-1)) + ceil(bb/(K-1)))
print(ret)

Solution (Python):
N, K = map(int, input().split())
print((N - 1 + K - 2) // (K - 1))

Solution (Python):
n, k = map(int, input().split())
print((n - 2) // (k - 1) + 1)

Solution (Python):
N,K=map(int,input().split())
print(-((1-N)//(K-1)))

Solution (Python):
import math
N, K = [int(i) for i in input().split()]
a = list(map(int, input().split()))
 
pos = a.index(1)
 
ans = math.ceil((N-1)/(K-1))
print(ans)

Solution (Python):
N,K=map(int,input().split())
if (N-1)%(K-1)==0:
    n=0
else:
    n=1
print((N-1)//(K-1)+n)

Solution (Python):
import math
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
print(math.ceil((N-K)/(K-1))+1)

Solution (Python):
N,K = map(int, input().split())
print(-(-(N-1)//(K-1)))

Solution (Python):
import math
N, K = map(int,input().split())
A = list(map(int,input().split()))

print(math.ceil((N-1)/(K-1)))

Solution (Python):
N,K=map(int,input().split());print(-((1-N)//(K-1)))

Solution (Python):
import math

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

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

l=(n-1)/(k-1)

m=math.ceil(l)

print(m)

Solution (Python):
import math
s=input().split()
n,k=int(s[0])-1,int(s[1])-1
print(math.ceil(n/k))

Solution (Python):
N,K = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
c = a.index(1)
naga = len(a)-K
if naga <= 0:
  print(1)
else:
  d = c-0
  if d != 0:
    V = K-1
    ans += d // V
    if d % V != 0:
      ans += 1
  e = N-1-c
  if e != 0:
      V = K-1
      ans += e // V
      if e % V != 0:
        ans += 1
  ans1 = 0
  ans2 = 0
  if d <= K-1:
    ans1 += 1
    ex = e -(K-d-1)
    if ex >= 0:
      V = K-1
      ans1 += ex // V
      if ex % V != 0:
        ans1 += 1
  else:
    ans1 = 999999999999999999999999999999
  if e <= K-1:
    ans2 += 1
    dx = d -(K-e-1)
    if dx >= 0:
      V = K-1
      ans2 += dx // V
      if dx % V != 0:
        ans2 += 1
  else:
    ans2 = 999999999999999999999999999999
  ans3 = 0
  ans4 = 999999999999999999
  V = K-1
  for i in range(K):
    ans3 = 0
    dx = d- i
    ex = e - (K - i - 1)
    ans3 += 1
    if dx > 0:
      if ex > 0:
        ans3 += ex//V
        if ex % V != 0:
          ans3 += 1
        ans3 += dx//V
        if dx % V != 0:
          ans3 += 1
        ans4 = min(ans4,ans3)
  print(min(ans,ans1,ans2,ans4))

Solution (Python):
input_line = input().split()

num_array = int(input_line[0])
num_equal = int(input_line[1])

input_line = input()
array_str = input_line.split()

array = list(map(int, array_str))

for index, number in enumerate(array):
    if number == 1:
        index_min = index
        break



equalized = 1
i = 1
while equalized < num_array:
    equalized += (num_equal - 1)
    
    i += 1

print(i - 1)

Solution (Python):
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
print((N - 1) // (K - 1) + int((N - 1) % (K - 1) != 0))

Solution (Python):
data = input().split()
N = int(data[0])
K = int(data[1])
count = 0

while N > K:
   N = N - K + 1
   count += 1

print(count + 1)

Solution (Python):
n, k = map(int, input().split(" "))
nums = list(map(int, input().split(" ")))

nums_len = len(nums)

count = 0

index = nums.index(1)

former = index
later = nums_len - index - 1

former_c = (former + (k-2)) // (k-1)
later_c = (later + (k-2)) // (k-1)

f_mod = ((k-1) - former % (k-1)) % (k-1)
l_mod = ((k-1) - later % (k-1)) % (k-1)


count = former_c + later_c

if f_mod + l_mod >= k - 1:
    count -= 1

print(count)

Solution (Python):
n,k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
print((n-2)//(k-1)+1)

Solution (Python):
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
one = a.index(1)

hidari = one
migi = n - (one+1)

mini = 10**10
for i in range(k):
    hidarii = hidari - i
    migii = migi - (k - 1 - i)
    if hidarii < 0 or migii < 0:
        continue
    
    
    if hidarii == 0:
        cnt = (migii - 1)//(k-1) + 1
    elif migii == 0:
        cnt = (hidarii - 1)//(k-1) + 1
    else:
        cnt = (migii - 1)//(k-1) + 1 + (hidarii - 1)//(k-1) + 1
    mini = min(cnt, mini)
print(mini + 1)

Solution (Python):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
for i in range(a[0]):
	if b[i] == 1:
		c = i
k = (a[0] - 1) // (a[1] - 1)
 
if (a[0] - 1) % (a[1] - 1) != 0:
	k += 1


print(k)

Solution (Python):
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
print((n - 1 + k - 2) // (k - 1))

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

if k == n:
	print(1)
elif 2 * k > n:
	print(2)
else:
	one_index = a.index(1)

	if one_index == 0 or one_index == n - 1:
		print((n - 2) // (k - 1) + 1)
	elif one_index <= k - 1 or n - one_index - 1 <= k - 1:
		print((n - 2) // (k - 1) + 1)
	else:
		print(min((one_index - 1) // (k - 1) + (n - one_index - 2) // (k - 1) + 2, (n - 2) // (k - 1) + 1))

Solution (Python):
n, k = map(int, raw_input().split())

print ((n-1) / (k-1) + ((n-1) % (k-1) != 0))

Solution (Python):


def cnt(C, K):
    c = C // (K - 1)
    if C % (K - 1) > 0:
        c += 1
    return c


def main():
    N, K = [int(e) for e in input().split(' ')]
    A = [int(e) for e in input().split(' ')]
    assert len(A) == N

    op = A.index(1)

    ans = cnt(op, K) + cnt(N - op - 1, K)
    ans = min(ans, cnt(N - 1, K))

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N, K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
pos_1 = A.index(1)
former = pos_1
latter = N - 1 - pos_1
ans = 0
s = min(former, latter)
l = max(former, latter)
if N == K:
  ans = 1
else:
  ans += s // (K-1)
  if s % (K-1) != 0:
    ans += 1
    l -= K - s % (K -1) - 1
  ans += l // (K-1)
  if l % (K-1) != 0:
    ans += 1
print(ans)

Solution (Python):

import sys
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)






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

    i = A.index(1)

    
    l = i // (K-1)
    r = (N-i-1) // (K-1)

    rest_left = i - l*(K-1)
    rest_right = (N-i-1) - r*(K-1)
    rest = N - (l+r) * (K-1)


    if rest_left == 0 and rest_right == 0:
        print(l+r)
    elif rest_left == 0 or rest_right == 0:
        print(l+r+1)
    elif rest <= K:
        print(l + r + 1)
    else:
        print(l+r+2)

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

ans = n - k + 1
i1 = -1
for i in range(n):
    if a[i] == 1:
        i1 = i
        break
for i in range(max(i1 - k + 1, 0), i1 + 1):
    ans = min(ans, (i + k - 2) // (k - 1) + (n - i - 2) // (k - 1) + 1)

print(ans)

Solution (Python):
N,K = map(int,input().split())
src = list(map(int,input().split()))
ans = 1
n = K
while n < N:
    n += (K-1)
    ans += 1
print(ans)

Solution (Python):
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)

Solution (Python):
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
print(-((1-N)//(K-1)))

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, A):
    for i, a in enumerate(A):
        if a == 1:
            break

    l = A[:i]
    r = A[i+1:]
    ans = math.ceil((len(l)+len(r)) / (K-1))


    return ans


def main():
    N, K = read_int_n()
    A = read_int_n()
    print(slv(N, K, A))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

N, K = rdi()
A = rdi()


x = (N-1) / (K-1)
y = (N-1) % (K-1)
if y:
        x += 1

print x

Solution (Python):
N, K = map(int,input().split())
A = list(map(int,input().split()))
n = A.index(min(A))
n2 = N-1-n
a,b = divmod(n,K-1)
c,d = divmod(n2,K-1)
if b == d == 0:
    print(a+c)
elif b+d < K:
    print(a+c+1)
else:
    print(a+c+2)

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
min = 100001
d = 0
for i in range(n):
	if a[i]<min:
		min=a[i]
		d = n

b = int((n-1)/(k-1))
if (n-1)%(k-1) != 0:
	b += 1

print(b)

Solution (Python):
N, K = [int(a) for a in input().split()]
ans = (N-1) // (K-1) + ((N-1) % (K-1)> 0)
print(str(ans))

Solution (Python):
def inpl(): return map(int, input().split())

N, K = inpl()
A = list(inpl())
i = A.index(1)

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

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

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

b = min(a)

i = 0
result = 0
while i < n:
  if a[i] == b:
    i += 1
    continue
  result += 1
  hoge = i + k
  if i + k > n:
    break
  if min(a[i:hoge]) == b:
    i += k
  else:
    i += k - 1

print(result)

Solution (Python):
import math
n,k = map(int, input().split())
a = list(map(int, input().split()))

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

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))
print((N - 2) // (K - 1) + 1)

Solution (Python):
def ii():
    return int(input())


def lii():
    return list(map(int, input().split(' ')))


def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l


def lv(N):
    l = []
    for _ in range(N):
        l.append(input())
    return l


def main():
    N, K = lii()
    a = lii()
    min_ix = None
    for i, v in enumerate(a):
        if v == 1:
            min_ix = i
            break

    def t(n, k):
        if n <= 0: return 0, 0

        ans = n // k
        if n % k:
            ans += 1
        return ans, n % k

    if N-1 - min_ix >= K-1 and min_ix >= K-1:
        ans1, p1 = t(min_ix, K-1)
        ans2, p2 = t(N-1 - min_ix, K-1)
        ans = ans1 + ans2
        if p1 > 0 and p2 > 0 and p1 + p2 <= K-1:
            ans -= 1
        return ans

    elif min_ix < K-1:
        d = K-1 - min_ix
        ans, _ = t(N-1 - min_ix - d, K-1)
        return 1 + ans

    elif N-1 - min_ix < K-1:
        d = K-1 - (N-1 - min_ix)
        ans, _ = t(min_ix - d, K-1)
        return ans + 1


if __name__ == '__main__':
    print(main())

Solution (Python):
import math

N,K=map(int, raw_input().split())
A=map(int, raw_input().split())
i=A.index(1)

ans=99999999
for k in range(K):
    tmp=1
    kk=(K-1)-k
    lefti=max(0, i-k)
    righti=min(N-1, i+kk)
    left= int(math.ceil((lefti)/float(K-1)))
    right= int(math.ceil((N-righti-1)/float(K-1)))
    ans=min(ans, tmp+left+right)
print ans

Solution (Python):
import math

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

pos = a.index(1)


cnt_base = math.ceil( ( n-k ) / (k-1) ) + 1

print(cnt_base)

Solution (Python):
import sys
import math
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
a=0
for i in range(N):
    if A[i]==1:
        a=i
        break
if a <=K-1:
    print(math.ceil((N-K)/(K-1))+1)
    sys.exit()
if N-K<=a:
    print(math.ceil((N-K)/(K-1))+1)
    sys.exit()
print(math.ceil((N-K)/(K-1))+1)

Solution (Python):
n,k=map(int, input().split())
a=list(map(int, input().split()))
b=a.index(1)
print((n+k-3)//(k-1))

Solution (Python):
n, k = map(int, input().split())

if n == k:
    print(1)
else:
    i = 0
    for i, a in enumerate(map(int, input().split())):
        if a == 1:
            break
    left = (i - 1) // (k - 1) + 1
    lr = (k - 1) * left + 1
    print(left + (n - lr - 1) // (k - 1) + 1)

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

start = a.index(1) + 1
left = (start - 1) // (k - 1) + 1
new_start = (k - 1) * left + 1
right = (n - new_start - 1) // (k - 1) + 1
count = left + right
print(count)

Solution (Python):
n, k = [int(i) for i in input().split()]
numbers = [int(i) for i in input().split()]

counter = 0
idx = 1
while idx < n:
    idx -= 1
    counter += 1
    idx += k
    
print(counter)

Solution (Python):
import numpy as np

def solve(N, K, As):
    return int(np.ceil((N-1) / (K-1)))

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

Solution (Python):
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))





print(ceil((N - 1) / (K - 1)))

Solution (Python):
import math
def find_min(length, window_size):
    return math.ceil((length-window_size)/(window_size-1)) + 1

args = input().split(" ")
length = int(args[0])
window_size = int(args[1].rstrip())
array = input().split(" ")

print(find_min(length, window_size))

Solution (Python):
n,k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
if (n-1)%(k-1) == 0:
    ans = (n-1)//(k-1)
else:
    ans = (n-1)//(k-1)+1
print(ans)

Solution (Python):
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(ceil((N-1) / (K-1)))

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

import math
ans = 0
if len(a)<=k:
  ans = 1
else:
  ans+=1+math.ceil((len(a)-k)/(k-1))

print(ans)

Solution (Python):
import math
N, K = map(int, input().split())
A = input().split()
print(math.ceil((N - 1) / (K - 1)))

Solution (Python):
n, m = map(int, input().split())
a = list(map(int, input().split()))
j = -1
num = float("inf")
for i in range(n):
    if a[i] < num:
        num = a[i]
        j = i

ans = 0
k = i
while k > 0:
    k = max(0, k - m + 1)
    ans += 1

l = i
while l < n - 1:
    l = min(n - 1, l + (m - 1))
    ans += 1

print(ans)