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):
import math
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
for i in range(len(a)):
    if a[i]==1:
        p1=i

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

Solution (Python):
import math

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

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

Solution (Python):
str = input()
n, k = str.split(' ')
ni = int(n)
ki = int(k)
str = input()

if ni == ki:
    print(1)
elif ki == 2:
    print(ni-1)
elif ((ni-1)%(ki-1) == 0):
    print(int((ni-1)/(ki-1)))
else:
    print(int((ni-1)/(ki-1))+1)

Solution (Python):
N,K=(int(i) for i in input().split())
A = list(int(i) for i in input().split())  
minNum=0
i=0
A2=[]
ans=0

while i<N:    
   
    if i==0:
        i=i+K
    else:
        i=i+K-1

    ans+=1
    
print(ans)

Solution (Python):
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
x = A.index(1)
y = x + 1
c = 0
a = (math.ceil((y-1)/(K-1))) * (K-1) + 1
c += math.ceil((y-1)/(K-1))
c += math.ceil((N-a)/(K-1))
print(c)

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

Solution (Python):
import sys

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

for k in range(N):
    if(A_list[k] == 1):
        k1 = k + 1
        break

ans = sys.maxsize

for k in range(k1 - K + 1, k1 + 1):
    
    if(k < 1):
        continue
    tmp_ans = 1
    tmp_ans += (k - 1) // (K - 1)
    if((k - 1) % (K - 1) != 0):
        tmp_ans += 1

    if(k + K <= N):
        tmp = N - k - K + 1
        tmp_ans += tmp // (K - 1)
        if(tmp % (K - 1) != 0):
            tmp_ans += 1

    
    if(ans > tmp_ans):
        ans = tmp_ans

print(ans)

Solution (Python):
N,K=[int(i) for i in input().split()]
A=[i for i in input().split()]
if N==K:
    print(N//K)
for i in range(100000):
    if K+1+(K-1)*i<=N and N<=K+(K-1)+(K-1)*i:
        print(i+2)
        break

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



if N==K:
    print(1)
elif K==2:
    print(N-1)
elif K==3:
    tmp = N//(K-1)
    if N%(K-1) == 2:
        print(tmp+1)
    else:
        print(tmp)
else:
    tmp = N//(K-1)
    print(tmp + (1 if N%(K-1) != 0 else 0))

Solution (Python):

import math

def up(n):
    print(n % 1)

if __name__ == "__main__":
    n,k = map(int,input().split())
    a = input().split(" ")
    prev = True
    pre,post = (0,0)
    remain = k
    result = 0
    for i in range(n):
        a[i] = int(a[i])
        if a[i] != 1 and prev == True:
            pre += 1
        if a[i] == 1:
            prev = False
            result += int(pre / (k-1)) + 1
            remain = k - (pre % (k-1) + 1)
            continue
        if prev == False and remain > 0:
            a[i] = 1
            remain -= 1
            continue
        if a[i] != 1 and prev == False:
            post += 1

    result += math.ceil(post / (k-1))

    print(result)

Solution (Python):
import math
def main15():
    strbuf1 = input('');
    strbuf2 = input('');
    strbufs1 = strbuf1.split();
    strbufs2 = strbuf2.split();
    buf1 = [];
    buf2 = [];
    ba = 0;
    for i in range(2):
        buf1.append(int(strbufs1[i]));
    for i in range(buf1[0]):
        buf2.append(int(strbufs2[i]));
        if(buf2[i] == 1):
            ba = i;
            break;
    are = buf1[1] - 1;
    kai1 = math.ceil(ba/are);
    kk = are * kai1 - ba;
    kai2 = math.ceil((buf1[0] -(ba+1+kk))/are)
    print(int(kai1+kai2));

def main16():
    strbuf = input('');
    num = int(strbuf);
    kazu = 0;
    number = 1;
    while(kazu<num):


        kazu = kazu + 1;

        number = number + 1;


if __name__ == '__main__':
    main15()

Solution (Python):
from math import ceil

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

count = 0
N -= K
count += 1

count += ceil(N/(K-1))
print(count)

Solution (Python):


def A(n,k,array,i):
	count = n
	if k >= n:
		count = 1
	elif i == n-1:
		count = int(-(-(n-1)/k-1)) 
	else:
		count = -(-(n-1)//(k-1))
	return count

	
	
baseinfo = input().split(" ")
baseinfo = [int(c) for c in baseinfo]
n, k = baseinfo[0], baseinfo[1]

array = input().split(" ")
array = [int(c) for c in array]


print(A(n, k, array, array.index(1)))

Solution (Python):





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

for i in range(N):
    if A[i] == 1:
        min_index = i

left = min_index + 1
count = 0
while left > 1:
    left -= K-1
    count += 1
if left == 1:
    left = 0
else:
    left -= 1

right_start = N - (min_index + 1) + left + 1
while right_start > 1:
    right_start -= K-1
    count += 1

print(count)

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

    mindex = a.index(1)

    min_t = 10000000
    for i in range(mindex-k+1, mindex+1):
        if i >= 0:
            t = 1 + (i+k-2) // (k-1) + (len(a)-(i+k-1)-1+k-2) // (k-1)
            min_t = min(t, min_t)

    print(min_t)


if __name__ == '__main__':
    main()

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


ans = (n-1)//(k-1) + min((n-1)%(k-1),1)
print(ans)

Solution (Python):
N, K = list(map(int, input().strip().split(" ")))
A = list(map(int, input().strip().split(" ")))
min_index = A.index(min(A))
action = 0

q, mod = divmod(min_index, K-1)
m = q
if((mod != 0) or (mod == 0 and q == 0)):
    m += 1
action += m 
res_list_length = N - (K + (m - 1)*(K - 1)) 
if(res_list_length != 0):
    res_list_length += 1
q, mod = divmod(res_list_length - 1, K-1)
m = q
if((mod != 0)  or (mod == 0 and q == 0)):
    m += 1
action += m 
print(action)

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

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

Solution (Python):


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

A = sorted(A_raw) 
N = int(n)
K = int(k)

lef = N - K 

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

elif lef%(K-1) == 0:
    ans = lef // (K-1) + 1

print(ans)

Solution (Python):
nk = input().split(" ")
n = int(nk[0])
k = int(nk[1])
a = input()
s = -(-(n-1) // (k-1))
print(s)

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

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

X = A.index(1) 

if X<K or N-K<=X:
    ans = 1+((N-K)//(K-1))
    if (N-K)%(K-1)>0: ans += 1
    print(ans)
else:
    min_ans = N
    for i in range(K):
        LR = [X-K+i+1,N-X-1-i]
        
        ans = 1
        for a in LR:
            ans += a//(K-1)
            if a%(K-1)>0: ans += 1
        if ans < min_ans: min_ans = ans
    print(min_ans)

Solution (Python):


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

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

for i in range(len(a)):
    if a[i]==1:
        num=i
count=0
num0=num
num1=num

while(1):
    num+=(k-1)
    count+=1
    if num>=n:
        num0-=num-n
        break

while(1):
    if num0<=1:
        break
    num0-=(k-1)
    count+=1
count2=0
num01=num1
while(1):
    num01-=(k-1)
    count2+=1
    if num01<=1:
        num1+=1-num01
        break
while(1):
    if num1>=n:
        break
    num1+=(k-1)
    count2+=1
print(min(count,count2))

Solution (Python):
N,K = map(int,input().split())
num = list(sorted(map(int,input().split())))
cnt = 0
while num[0]!=num[-1]:
  for i in range(1,K):
    if cnt<1:
      num[i]=num[i-1]
    else:  
      j = (K-1)*cnt
      if i + j>=num[-1]:
        break
      num[i+j]=num[j]
      
  cnt+=1
print(cnt)

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

a = [0]
a = input().split()

b = a.index('1')

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

print(s)

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

ans = 0

while True:
    if n > k:
        ans += 1
        n -= (k-1)
    else:
        ans += 1
        break

print(ans)

Solution (Python):
def main():
    N, K = [int(x) for x in input().strip().split()]
    line = [int(x) for x in input().strip().split()]
    counter = K - 1
    result = 0
    while counter < N:
        counter += K - 1
        result += 1
    if counter - (K - 1) < N - 1:
        result += 1
    print(result)


if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
x = 0
while N > 0:
    if x == 0:
        N = N - K
        x += 1
    else:
        N = N - (K-1)
        x += 1
print(x)

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

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

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

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

Solution (Python):
import math

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

x=A.index(1)



B=math.ceil(x/(K-1))




if B==0:
    y=1
else:
    y=(B-1)*(K-1)+K



C=math.ceil((N-y)/(K-1))



print(B+C)

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

Solution (Python):
q="C"
if q=="A":
	S=input()
	print(sum((i=="+")-(i=="-")for i in S))
if q=="B":
	a=int(input())
	b=sum(int(i) for i in str(a))
	print("Yes" if a%b==0 else "No")
if q=="C":
	N,K=map(int,input().split())
	A=[int(i) for i in input().split()]
	func=lambda a,b:int(a/b) if a%b==0 else int(a/b+1)
	print(1+func((len(A)-K),K-1))
if q=="D":
	K=int(input())
	S=lambda x:sum(int(i) for i in str(x))
	
	r=0
	for i in range(1,10**15):
		a=i
		b=int(K/10)*10+9
		if a/S(a)<=b/S(b):
			print(a)
			r+=1
			if r==K:
				break

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

if K == 2:
    print(N-1)
elif N % (K-1) > 1:
    print(N // (K-1) + 1)
else:
    print(N // (K-1))

Solution (Python):
N,K = map(int,input().split())
counter = 0

A = input().split()
while (1+counter*(K-1)<N):
  
  





  counter +=1

print(counter)

Solution (Python):


import math

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

    print(max(1, math.ceil((len(A) - K) / (K-1)) + 1))

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


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

Solution (Python):
N, K = 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=input().split()
n,k=[int(n),int(k)]
a=[int(i)for i in input().split()]
i=1
c=0
while i<=n:
    c+=1
    i+=(k-1)
    if i==n:
        break
print(c)

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

m = 1
while True:
    if m*k - (m-1) >= n:
        print(m)
        break
    else:
        m += 1

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

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

count_1 = index
count_2 = n - index -1

r = count_1 % (k-1)
if r == 0:
    q_1 = count_1 // (k-1)
else:
    q_1 = count_1 // (k-1) + 1

if r == 0:
    count_3 = count_2
else:
    count_3 = count_2 - ((k-1) - r)

if count_3 < 0:
    q_2 = 0
elif count_3 % (k-1) == 0:
    q_2 = count_3 // (k-1)
else:
    q_2 =  count_3 // (k-1) +1

ans = q_1 + q_2

print(int(ans))

Solution (Python):
def solve():
    n, k = map(int, input().split())
    a_list = list(map(int, input().split()))
    if n == k:
        return 1
    k = k - 1
    ans = 0
    if k == 1:
        return n - 1
    if n % 2 == 1 and k == 2:
        return int((n - 1) / k)
    if n % k == 0:
        ans = int(n / k)
    else:
        ans = int(n / k) + 1
    return ans


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

Solution (Python):
import math
N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
for i in range(100000):
    if (i-1) * K - (i - 2) < N <= i * K - (i - 1):
        res = i
        break
print(res)

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=min(a)
mc=sum([x == m for x in a])
nc=n-mc
print((nc+k-2)//(k-1))

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


def count(num, k):
    if num == 0:
        return 0
    elif num % (k - 1) == 0:
        return num // (k - 1)
    else:
        return num // (k - 1) + 1


min_index = a_list.index(1)
res = []
for i in range(k):
    pre_end_index = max(min_index - (k-1) + i, 0)
    suf_start_index = min(min_index + i, n-1)
    pre = count(pre_end_index, k)
    suf = count(n-1-suf_start_index, k)
    res.append(pre+suf+1)

print(int(min(res)))

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






n = N
ret = 0

n = n - K
ret += 1

while n > 0:
    n = n - (K - 1)
    ret += 1

print(ret)

Solution (Python):
from math import ceil

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

idx = 0
ans = 0
while idx < N - 1:
    ans += 1
    idx += K - 1

print(ans)

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

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

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

Solution (Python):
import sys
import math

imp = raw_input().strip().split(" ")
a = raw_input().strip().split(" ")
N = int(imp[0])
K = int(imp[1])
cnt = 0

while N > K :
    N = N - K + 1
    cnt += 1
print(str(cnt+1))

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

z = k
cnt = 1
while True:
    if z >= n:
        break
    z = (z - 1) + k
    cnt += 1
print(cnt)

Solution (Python):
N,K = (int(i) for i in input().split())
a = [int(x) for x in input().split()]

b= a.index(1)+1

if b/(K-1) == 0:
    answer = -(-(N-1)//(K-1)) +1

else:
    answer = -(-(N-1)//(K-1))

print(answer)

Solution (Python):
n,k=map(int,input().strip().split())
c=n
l=list(map(int,input().strip().split()))
ans=0
if n==k:
    print(1)
else:
    while True:
        if n<=0 or n==1:
            break 
        else:
            n=n-(k-1)
            ans+=1
    print(ans)

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if cnt==0:
        n=n-k
        cnt+=1
        
    else:
        n=n-(k-1)
        cnt+=1
        
    if n<=0:
        break
print(cnt)

Solution (Python):


import math
import sys
import itertools
import numpy as np

n,k = map(int, input().split())
a = [int(i) for i in input().split()]
x=n
for i in range(n):
    if a[i] == 1:
        x=i
        break

y = n - x - 1

p = (x-1)//(k-1) + (y-1)//(k-1) + 2
if (n-1) % (k-1) == 0:
    q = (n-1)//(k-1)
else:
    q = (n-1)//(k-1)+1

print(min(p,q))

Solution (Python):
N, K = map(int, raw_input().split())
A_N  = map(int, raw_input().split())
sum = 0

N_m_K     = N - K
N_m_K_div = (N_m_K - 1) / (K - 1)



if N == K:
    print 1
else:
    print (N_m_K_div + 1) + 1

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

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

Solution (Python):
import math

def f(n, k):
    if n == k:
        return 1
    return math.ceil((n-k)/(k-1)) + 1

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

print(f(N, K))

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


A_1 = A.index(1)


result = N
for i in range(K):
    
    tmp = 1
    left_d = A_1 - i
    right_d = N - A_1 - 1 - ( K - i - 1)
    
    
    while left_d > 0:
        tmp += 1
        left_d -= K - 1

    
    while right_d > 0:
        tmp += 1
        right_d -= K - 1
    
    if tmp < result:
        result = tmp

print(result)

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


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

Solution (Python):
def fun(n, m):
    key = 1
    n -= m
    key += n / (m - 1)
    if int(key) == key:
        return int(key)
    else:
        return int(key) + 1
    
N, K = map(int, input().split())
A = list(map(int, input().split()))
key = N / (K - 1)
print(fun(N, K))

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

buff = []
for i in range(K):
    before = min_idx - i
    after = N - (min_idx+1) - (K-1 - i)

    b = int(before / (K-1))
    a = int(after / (K-1))
    if (before % (K-1)) != 0:
        b += 1
    if (after % (K-1))!= 0:
        a += 1

    buff.append(a + b + 1)
print(min(buff))

Solution (Python):

import math


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


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

Solution (Python):
N, K = map(int, input().split())
input()
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 = list(map(int, input().split()))
if N != K:
    print((-(-(N-K) // (K-1))) + 1)
else:
    print(1)

Solution (Python):

N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
sum = K
ans = 0

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

print (ans)

Solution (Python):
import math

N, K = map(int, input().split(" "))
a = 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()))
a.sort()
where=a.index(1)
R=math.ceil((where)/(K-1))
L=math.ceil((N-where-1)/(K-1))
print(R+L)

Solution (Python):
N, K = map(int,input().split())
print((N-2)//(K-1)+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):
def c_minimization(N, K, A):
    import math
    ans = math.ceil((N-K)/(K-1))+1
    return ans

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(c_minimization(N, K, A))

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

pos = A.index(1) + 1

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

print(ans)

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

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
	if a[i]==1:
		break
p=i
k-=1


x=0
for j in range(n-1,p,-k):
	x+=1

for j in range(0,p,k):
	x+=1
y=p%k+1+(n-p-1)%k
if p%k>0 and (n-p-1)%k>0 and y<=k+1:
	x-=1
print(x)

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

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
i = 1
ans = 0
flag = False
while True:
    try:
        if(A == []):
            if(flag == False):
                print(ans)
            break
        if(ans == 0):
            for i in range(K):
                A.pop(0)
        else:
            for i in range(K-1):
                A.pop(0)
        ans += 1
    except:
        print(ans+1)
        flag = True

Solution (Python):
N, K = [int(c) for c in input().split()]
As = [int(c) for c in input().split()]
t = 1 if (N - 1) % (K - 1) else 0
print((N - 1) // (K - 1) + t)

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

Solution (Python):
n , k = map(int,input().split())
a = list(map(int,input().split()))
ans = 1
if k == n:
    print(ans)
else:
    for _ in range(k + 1,n + 1,k-1):
        ans += 1
    print(ans)

Solution (Python):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
i = A.index(1)
if K==N:
    print(1)
else:
    print( min(i//(K-1) + (N-i-1)//(K-1) + (i%(K-1)!=0) + ((N-i-1)%(K-1)!=0), ((N-1)//(K-1) + ((N-1)%(K-1)!=0) ) ) )

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

ans=0
i=0
while(i<len(A)-1):
    ar=[]
    try:
        ar=A[i:i+k]
    except:
        ar=A[i:len(A)]
    i=i+k-1
    ans=ans+1
print(ans)

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

def num(x,K):
    return(math.ceil(x/(K-1)))
    
left = A.index(1)
right = N-1-A.index(1)

left_noba = left % (K-1)
left_num = left // (K-1) + 1

right_noba = K - 1 - left_noba

if right >= right_noba:
    right_num = num(right - right_noba,K)
else:
    right_num = 0
    
print(left_num + right_num)

Solution (Python):
N,K = map(int,input().split())
A = [int(x) for x in input().split()]
count = 1
increment = K -1
while K < N:
    K = K + increment
    count += 1

print(count)

Solution (Python):
import sys
import math

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n,k = na()
a = na()

if n == k:
    print(1)
elif k >= n//2:
    print(2)
elif k == 2:
    print(n-1)
else:
    print(math.ceil((n-k)/(k-1))+1)

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

Solution (Python):
N,K=map(int,input().split())
A=[int(x) for x in 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_list = list(map(int, input().split()))
A_b = [0] * N

if N == K:
    print(1)
else:
    n = 1
    N -= K
    while N > 0:
        N -= (K - 1)
        n += 1
    print(n)

Solution (Python):


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

max_idx = a.index(min(a))

left = a.index(min(a))
right = n - left - 1

res = 0

left_mod = left % (k - 1)
res += left // (k - 1)

right_mod = right % (k - 1)
res += right // (k - 1)

if left_mod == 0 and right_mod == 0:
    res += 0
elif k >= left_mod + right_mod + 1:
    res += 1
else:
    res += 2

print(res)

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



if N == K:
    print(1)
elif K == 2:
    print(N-1)
else:
    a = N // (K-1)
    if N - a*(K-1) >= 2:
        print(a+1)
    else:
        print(a)

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

idx = A_arr.index(1)
leftn = idx
rightn = N - idx - 1

c = []

for i in range(max(K - leftn - 1, 0), K):
    c.append(1 + ((leftn - (K-1-i)) + K-1-1) // (K-1) + ((rightn - i) + K-1-1) // (K-1))

print(min(c))

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

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

Solution (Python):






def ceil(src, range):
    return ((int)(src / range) + 1) * range


if __name__ == '__main__':
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    tmp = (n - 1) % (k - 1)

    if tmp == 0:
        print((n - 1) // (k - 1))
    else:
        print(ceil((n - 1) / (k - 1), 1))

Solution (Python):
nk=input().split()
n=int(nk[0])
k=int(nk[1])
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 = list(map(int, input().split()))

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

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

one_pos = 0
for i, num in enumerate(a):
    if num == 1:
        one_pos = i
        break
count = (i - 1) // (K - 1) + 1
if count * (K - 1) >= len(a):
    pass
else:
    if count * (K - 1) + 1 > i + 1:
        count += (len(a) - (count * (K - 1) + 1) - 1) // (K - 1) + 1
    else:
        count += (len(a) - (i + 1) - 1) // (K - 1) + 1
print(count)

Solution (Python):

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

for i in range(N):
    if nums[i] == "1":
        index = i

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

    after = N - (total * (K-1) + 1)

    if after % (K-1) == 0:
        total += after // (K-1)
    else:
        total += after // (K-1) + 1

    print(total)

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

y = N - x - 1
ans = float("inf")


def ceil(m, n):
    return -(-m // n)


for s in range(K):
    t = K - 1 - s
    ans = min(ans, ceil(y - t, K - 1) + ceil(x - s, K - 1))

print(ans + 1)

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

if n == k :
    print(1)

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

Solution (Python):
N, K = [int(i) for i in input().split()]
A = [int(i) for i in 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=list(map(int,input().split()))
idx=A.index(1)
cnt=0
if idx:
    if idx+1<=K:
        cnt=1
        A[:K]=[1]*K
    else:
        cnt=(idx-1)//(K-1)+1
        num=cnt*(K-1)+1
        A[:num]=[1]*num
A=A[::-1]
idx=A.index(1)
if idx:
    if idx+1<=K:
        cnt+=1
        A[:K]=[1]*K
    else:
        cnt+=(idx-1)//(K-1)+1
        num=cnt*(K-1)+1
        A[:num]=[1]*num
print(cnt)

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i, v in enumerate(a):
    if v == 1:
        ind1 = i
        break

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

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

while n>0:
    n-=(k-1)
    ans+=1

print(ans)

Solution (Python):
n,k = map(int,input().split())
a = input()
g = n - k
if k > n :
    print(0)
else:
    t = 1
    while  0 < g :
        g = g - (k-1)
        t += 1
print(t)

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

if(N==K):
    print("1")
elif(K>=(N/2)):
    print("2")
elif(3<=K and K<(N/2)):
    print((N-(K+1))//(K-1)+2)
else:
    print(N-1)

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

Solution (Python):
n, k = map(int, input().split())
cnt = 0
ans = 1
while True:
    ans += k-1
    cnt += 1
    if ans >= n:
        break
print(cnt)

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

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

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

Solution (Python):


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

for i in range(1, N):

    if (K - 1) * i + 1 >= N:
        print(i)
        exit()

Solution (Python):



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

tN = N - K

ans = -(-tN // (K-1)) + 1
print(ans)

Solution (Python):


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

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

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

ans_left = (place_one+(K-2))//(K-1)

ans_left += (N-(K-1)*ans_left+(K-3))//(K-1)


ans_right = (N-1-place_one+(K-2))//(K-1)

ans_right += (N-1-(K-1)*ans_right+(K-2))//(K-1)


print(min(ans_left,ans_right))

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

if k == 2:
    print(n-1)

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

Solution (Python):
import math

x,y = map(int,input().split())
input()

low = math.floor(x / (y - 1))
high = math.ceil(x / (y - 1))

if low == high:
    low = low - 1

if ((y - 1) * low) + 1 >= x:
    print(low)
else:
    print(low + 1)

Solution (Python):
import math

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

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

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



if __name__ == "__main__":
    main()

Solution (Python):
import math

(n, k) = tuple(map(int, input().split()))
arr = list(map(int, input().split()))
one = arr.index(1)
if k == n:
    print(1)
else:
    res1 = math.ceil(one / (k - 1))
    one1 = (k - 1) * res1
    res1 += math.ceil((len(arr) - one1 - 1) / (k - 1))

    arr.reverse()
    res2 = math.ceil(one / (k - 1))
    one2 = (k - 1) * res2
    res2 += math.ceil((len(arr) - one2 - 1) / (k - 1))
    print(min(res1, res2))

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

import numpy as np
a = np.array(a)
a1 = np.where(a == 1)[0][0]
ar = len(a) - a1 - 1
al = a1

if ar > al:
    while True:
        if ar % (k-1) == 0 or al % (k-1) == 0:
            break            
        ar -= 1
        al += 1

if ar <= al:
    while True:
        if ar % (k-1) == 0 or al % (k-1) == 0:
            break            
        ar += 1
        al -= 1


nr = int(np.ceil(ar / (k-1)))
nl = int(np.ceil(al / (k-1)))

ans = nr + nl

print(ans)

Solution (Python):
N, K = list(map(int,input().strip().split(' ')))
A = list(map(int,input().strip().split(' ')))
tmp = N-K
ans = 1
flg = 0
while tmp >= 0:
    if tmp == 0:
        print(ans)
        flg = 1
        break
    tmp = tmp - (K-1)
    ans = ans + 1

if flg ==0:
    print(ans)

Solution (Python):
import sys
import math
if __name__ == "__main__":
    N, K = list(map(int, (input().split(' '))))
    A = list(map(int, (input().split(' '))))
    min = math.ceil(((N - 2) + 1) / (K - 1))
    print(min)

Solution (Python):
from math import ceil

if __name__ == '__main__':
    n, k = map(int, input().split())
    a_str = input().split()
    a = []
    a_min = n + 1
    a_min_index = 0
    for i, a_i_str in enumerate(a_str):
        a_i = int(a_i_str)
        if a_i < a_min:
            a_min = a_i
            a_min_index = i

    n_left_elements = a_min_index
    left_count = ceil(n_left_elements / (k - 1))

    right_index_start = left_count * (k - 1)
    right_count = ceil((n - right_index_start - 1) / (k - 1))

    ans = left_count + right_count
    print(ans)

Solution (Python):



import math

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

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

minNum = min(a)

li = len([i for i in range(len(a)) if minNum == a[i]])


print(math.ceil((len(a)-li)/(k-1)))