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 sys

def solve(N: int, K: int, A: "List[int]"):
    from math import ceil
    return ceil((N-1)/(K-1))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    print(solve(N, K, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k, *a = map(int, read().split())
    if n <= k:
        print(1)
        sys.exit()
    else:
        r = ceil((n - 1) / (k - 1))
        print(r)
if __name__ == '__main__':
    main()

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

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

Solution (Python):
import math

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

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

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

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 sys,math
input = sys.stdin.readline

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

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

Solution (Python):
N,K=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
for i in range(10**5+1):
    N-=K
    cnt+=1
    if N<=0:
        break
    else:
        N+=1
print(cnt)

Solution (Python):
import math
N, K = list(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()))

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

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

Solution (Python):
from math import ceil
n,k = map(int,input().split(" "))


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

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

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

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

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

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

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

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

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

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

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

Solution (Python):
n, k = map(int, input().split())
lst = list(map(int, input().split()))
idx = lst.index(1)
k -= 1
a = (len(lst[:idx]) + k - 1) // k
b = (len(lst[idx + 1:]) + k - 1) // k
c = ((n - 1) + k - 1) // k
print(min(c, a + b))

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

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

Solution (Python):
import math

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

ans = 0

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

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

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
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)
ans = 10**9
for j in range(K):
    ans = min(ans,math.ceil(max(i-j,0)/(K-1))+math.ceil(min((N-i-1+j),N-1)/(K-1)))
print(ans)

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

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, k = MI()
    a = LI()
    ans = -(-(n-1) // (k-1))
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import math

n, k = map(int, input().split())
lis = 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()))
b=min(A)
p=0
for i in range(N):
  if A[i]!=b:
    p+=1
if p%(K-1)==0:
  print(p//(K-1))
else:
  print(p//(K-1)+1)

Solution (Python):
n,k=map(int,input().split())
l=list(map(int,input().split()))
if n<=k:
    print(1)
    exit()
c=1
while 1:
    if n<=k:
        break
    n-=(k-1)
    c+=1
print(c)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def func(n, k):
    """
    n個のものをk個ずつ重なり1でとる回数
    """
    if n <= 1: return 0
    if n <= k: return 1
    if (n - k) % (k - 1) == 0: return 1 + (n - k) // (k - 1)
    return 1 + (n - k) // (k - 1) + 1

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    place = 0
    for i in range(N):
        if A[i] == 1:
            place = i
            break
    """
    1を常に端点にとると失敗する！
    反例：A=[2,3,4,1,5,6,7], K=3
    """
    ans = 10**10
    for i in range(K):
        ans1 = func(place - i + 1, K)
        ans2 = func((N - place) - (K - i) + 1, K)
        
        ans = min(ans, ans1 + ans2 + 1)
    print(ans)

if __name__ == "__main__":
    main()

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

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 main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 0
    for x in range(1, N+1):
        if (K-1)*x + 1 >= N:
            ans = x
            break
    print(ans)
main()

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

Solution (Python):

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

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

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

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

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
input = sys.stdin.readline

def main():
	N,K=map(int,input().split())
	A=list(map(int,input().split()))
	if (N-1)%(K-1):
		print((N-1)//(K-1)+1)
	else:
		print((N-1)//(K-1))
if __name__=='__main__':
	main()

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

ans = 1
N -= K

while N > 0:
    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):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

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

    ans = 1
    N -= K
    ans += (N + K - 2)//(K - 1)
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
import bisect
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N==K: print(1);exit()
N-=K
ans = 1
while N>0:
    N -=K-1
    ans += 1
print(ans)

Solution (Python):
N, K = map(int, input().split())
Ax = list(map(int, input().split()))
if N == K:
    print(1)
    exit()

N -= K
ans = 1

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

print(ans)

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

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))
eq = 1
cnt = int()
while eq<N:
    eq += (K-1)
    
    cnt +=1

print(cnt)

Solution (Python):
import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
start = 0
end = k
count = 0
for i in range(n):
    if a[n-1]==1:
        print(count)
        sys.exit()
    a[start:end] = [1]*k
    start += (k-1)
    end += (k-1)
    count += 1

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

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

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

print(ans)

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

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

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

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

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


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


    print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, k = map(int, readline().split())
    print((((n-k)+(k-1)-1)//(k-1))+1)
if __name__ == '__main__':
    main()

Solution (Python):
from bisect import bisect_left

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

pos = bisect_left(a, 1)
print((pos + k - 2) // (k - 1) + (n - pos + k - 3) // (k - 1))

Solution (Python):
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 - 1 - index - (K - 1 - leftamari if leftamari != 0 else 0)) / (K-1))
    print(left + right)

Solution (Python):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

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

if __name__ == "__main__":
    main()

Solution (Python):
import math
s = list(map(int, input().split()))
n=s[0]
k=s[1]-1
s = list(map(int, input().split()))
ind=s.index(1)

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

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

Solution (Python):
N, K = map(int,input().split())
AN = list(map(int,input().split()))
AN.sort()
N = N - AN.count(AN[0])

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

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

Solution (Python):
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
"""
すべて1にする
"""
print(math.ceil((n-k)/(k-1))+1)

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))

def main():
    n, k = MII()
    aa = MII()
    print((-(-(n-1)//(k-1))) if n > 3 else 1)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
ans=(n-1)//(k-1)
if (n-1)%(k-1)!=0:
  ans+=1
print(ans)

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

Solution (Python):
n,k=map(int,input().split())
i=1
cnt=0
while i<n:
  i+=k-1
  cnt+=1
print(cnt)

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


pos = A.index(1)

count = 0
num_forward = pos  
num_backward = N - pos - 1  


rest = num_forward % -(K - 1)
num_backward += rest

while num_forward > 0:  
    num_forward -= K - 1
    count += 1
while num_backward > 0:  
    num_backward -= K - 1
    count += 1
print(count)

Solution (Python):
import math
n,k = map(int,input().split())
ls = 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()))
N -= K
K -= 1
ans = 1
ans += (N-1)//K + 1
print(ans)

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

ans = 1
tmp = N - K
ans += tmp // (K - 1)

if tmp%(K - 1) != 0:
    ans += 1

print(ans)

Solution (Python):
n, k = map(int, input().split())
m = n - 1
l = k - 1

if m % l == 0:
    print(m // l)
else:
    print(m // l + 1)

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

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = lr()
answer = -(-(N-1)//(K-1))
print(answer)

Solution (Python):

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


N -= K

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

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

for i,v in enumerate(x):
    if v == 1:
        r = i
a,b = divmod(r,k-1)
if b > 0:
    a += 1
r = a * (k-1)

l = n-r-1
if l > 0:
    c,d = divmod(l, k-1)
    if d > 0:
        c += 1
    a += c

print(a)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7



N, K = MAP()
A = LIST()

i = A.index(1)
print(ceil((N-1)/(K-1)))

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

N, K = getNM()
A = getList()
mi = min(A)
miindex = []
for i in range(N):
    if A[i] == mi:
        miindex.append(i)
ans = 1000000
for i in miindex:
    rang = K - 1
    opt1 = (i + rang - 1) // rang
    newi = opt1 * rang + 1
    opt2 = ((N - newi) + rang - 1) // rang
    ans = min(ans, opt1 + opt2)
print(ans)

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

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

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

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

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

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

print(ans)

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

Solution (Python):
import math
n,k = map(int,input().split())
a_list = 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()))
print(math.ceil((n - k) / (k - 1)) + 1)

Solution (Python):

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)))

Solution (Python):
Len, Split = map(int, input().split())
_res = (Len - 1) % (Split - 1)
if _res:
    res = int(((Len - 1) // (Split - 1)) + 1)
    print(res)
else:
    res = int((Len - 1) // (Split - 1))
    print(res)

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

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n = n//a
    count += 1
  if a**count == n:
    return count
  else:
    return count+1





N,K = IL()
A = IL()
p = A.index(1)

P(-(-(N-1)//(K-1)))

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

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

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

Solution (Python):
import math

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

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

if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())
an = list(map(int, input().split()))
mini = min(an)
need = 0
for a in an:
    if a != mini:
        need += 1
print(-(-need//(k-1)))

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

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

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

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

Solution (Python):
import math










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

Solution (Python):
import math
def resolve():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	i = a.index(min(a)) + 1
	if k - 1 > i:
		v = max(0, math.ceil((n - k - 2) / (k - 1))) + 1
	else:
		v = math.ceil(i / (k - 1)) + math.ceil((n - i - 1) / (k - 1))
	print(v)
resolve()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


n, k = Is()
A = LI()
ans = 1
tmp = n - k
if tmp > 0:
    ans += ceil(tmp/(k-1))
print(ans)

Solution (Python):

import re
import math
from collections import defaultdict
from collections import deque
from fractions import Fraction
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache

readline=sys.stdin.readline
sys.setrecursionlimit(2000000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def pm(x):
    return x//abs(x)
def inputintlist():
    return list(map(int,input().split()))

def main():
    N,K=inputintlist()
    A=inputintlist()
    N-=1
    K-=1
    ans=(N+K-1)//K
    print(ans)
main()

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

Solution (Python):
import math


def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    index_one = A.index(1)
    min_cnt = N
    for left_index in range(index_one - (K - 1), index_one + 1):
        right_index = left_index + (K - 1)
        if left_index < 0 or right_index > N - 1:
            continue
        cnt = 1 + math.ceil(left_index / (K - 1)) + math.ceil((N - 1 - right_index) / (K - 1))
        min_cnt = min([min_cnt, cnt])
    print(min_cnt)


if __name__ == '__main__':
    main()