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
import math


def main():
    """
    2 <= K <= N <= 10^5
    1 <= ai <= N
    1 <= i <= N
    """
    N, K = map(int, input().split())
    *A, = map(int, input().split())

    ans = f_K(N, K, A)
    
    print(ans)


def test_examples():
    nka_ans = [
        (4, 3, [2, 3, 1, 4], 2),
        (3, 3, [1, 2, 3], 1),
        (8, 3, [7, 3, 1, 8, 4, 6, 2, 5], 4),
    ]

    for N, K, A, ans in nka_ans:
        assert editorial(N, K, A) == ans
        assert f_K(N, K, A) == ans


def test_ans():
    nka_ans = [
        (5, 2, [1, 2, 3, 4, 5], 4),
        (5, 3, [1, 2, 3, 4, 5], 2),
        (5, 2, [5, 4, 3, 2, 1], 4),
        (5, 3, [5, 4, 3, 2, 1], 2),
    ]

    for N, K, A, ans in nka_ans:
        assert editorial(N, K, A) == ans
        assert f_K(N, K, A) == ans


def f_K(N, K, A):
    """
    最初に置く範囲は、 1_idx - K + 1 から 1_idx
    """
    idx = [i for i, a in enumerate(A) if a == 1][0]
    left_idx = max(0, idx - K)
    ans = float("inf")
    for i in range(left_idx, idx + 1):
        left = i
        right = max(0, N - left - K)
        tmp = (left + (K - 1) - 1) // (K - 1)
        tmp += 1
        tmp += (right + (K - 1) - 1) // (K - 1)
        ans = min(ans, tmp)

    return ans


if __name__ == '__main__':
    main()

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

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

Solution (Python):
NK = input()
Ain = input()
s = NK.index(" ")

N = int(NK[0:s])
K = int(NK[s+1:len(NK)+1])
n = N-1
k = K-1
a = int(n/k)
if n%k != 0:
    a += 1
print(a)

Solution (Python):
import sys


def solve(n, k, as1):
    if (n-1)%(k-1)==0:
        return (n-1)//(k-1)
    else:
        return (n-1)//(k-1)+1


def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_n, str_k] = line.split(' ')
    line = sys.stdin.readline().rstrip()
    as1 = line.split(' ')
    return (int(str_n), int(str_k), [int(a) for a in as1])

def main():
    n, k, as1 = readQuestion()
    answer = solve(n, k, as1)
    print(answer)
    
if __name__ == '__main__':
    main()

Solution (Python):
import sys

def solve(n, k, as1):
    if (n-1)%(k-1)==0:
        return (n-1)//(k-1)
    else:
        return (n-1)//(k-1)+1

def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_n, str_k] = line.split(' ')
    line = sys.stdin.readline().rstrip()
    as1 = line.split(' ')
    return (int(str_n), int(str_k), [int(a) for a in as1])

def main():
    n, k, as1 = readQuestion()
    answer = solve(n, k, as1)
    print(answer)
    
if __name__ == '__main__':
    main()

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

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

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

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

print(answer)

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
n-=1
while n>0:
    n+=1
    n-=k
    ans+=1
print(ans)

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

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())
a=list(map(int,input().split()))
for i in range(1,n):
    if n<=k+(k-1)*(i-1):
        print(i)
        exit()

Solution (Python):
import sys
N,K = map(int, input().split())
lis = [int(i) for i in input().split()]
if N == 1:
  print(0)
  sys.exit()
if N<=K:
  print(1)
  sys.exit()
ind = lis.index(1)+1
if (N-1)%(K-1)==0:
  print(int((N-1)/(K-1)))
else:
  print(int((N-1)//(K-1))+1)

Solution (Python):
n, k = input().split()
n = int(n)
k = int(k)
aa = input().split()
aa = [int(a) for a in aa]
ans = 0
nn = n
f = False
while nn > 0:
    if f:
        nn += 1
    f = True
    ans += 1
    nn -= k
print(ans)

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()))
ans = (n-1)//(k-1)
if (n-1)%(k-1) is not 0:
    ans+=1
print(ans)

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

Solution (Python):


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

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

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

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

Solution (Python):
N, K = map(int, input().split())
A = list(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):
import math
N,K = map(int,input().split())

input()

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

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

Solution (Python):
import math

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

N -= K

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

print (ans)

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

c = 0

while True:
    c += 1
    if n - k <= 0:
        break
    n = n - k + 1

print(c)

Solution (Python):
import math

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

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

Solution (Python):


import math
import sys

a,b = input().split(" ")

ans = math.ceil((int(a)-1) / (int(b)-1))
print(ans)

Solution (Python):
N, K = map(int, input().split())
arr = list(map(int, input().split()))
m = 1

c = 0
ans = 0
for i in arr:
  if i == 1:
    continue
  ans += 1
c += (ans + K - 2) // (K - 1)
print(c)

Solution (Python):




"""








"""
import math
import sys

def get_input():
    input_data = sys.stdin.readlines()
    N, K = input_data[0].split(" ")
    N = int(N)
    K = int(K)
    SEQ = [int(i) for i in input_data[1].split(" ")]

    assert len(SEQ) == N

    return N, K, SEQ

def get_minimum_distance(K, SEQ):
    """
    >>> get_minimum_distance(3, [2,3,1,4])  
    2
    >>> get_minimum_distance(3, [1,2,3])  
    1
    >>> get_minimum_distance(3, [7,3,1,8,4,6,2,5])

    """
    init_minimum_pos = SEQ.index(1)
    print("init:", init_minimum_pos)
    
    right_len = len(SEQ) - init_minimum_pos - 1 
    operation_num_right = math.ceil(right_len / K)
    print("右に実施する回数", operation_num_right)
    right_adj = right_len % K

    left_len = SEQ.index(1)
    residual = left_len - right_adj
    operation_num_left = math.ceil(residual / K)

    print(operation_num_right+operation_num_left)


if __name__ == '__main__':
    N, K, SEQ = get_input()
    print(math.ceil((N-1)/(K-1)))

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




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

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

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

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

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

Solution (Python):


N, K = map(int, input().split())
A = [input().split()]
i = 1
while N-K > 0:
    N = N-K +1
    i = i+1

print(i)

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

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):
import math
N,K = [int(i) for i in input().split()]

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

Solution (Python):
def solve(n, k, a):
    return (n+k-3) / (k-1)
assert solve(4, 3, [2,3,1,4]) == 2
assert solve(3, 3, [1,2,3]) == 1
assert solve(8, 3, [7,3,1,8,4,6,2,5]) == 4

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
print solve(n, k, a)

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


if (N-1) % (K-1) == 0:
    print(int((N-1)/(K-1)))
else:
    print((N-1)//(K-1) + 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())
input()

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

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

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

for g in range(n):
    if(n <= k + (k - 1) * (g - 1)):
        print(g)
        sys.exit()

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

Solution (Python):
N,K=map(int, input().split())
A=input()
if (N-1)%(K-1):
    print((N-1)//(K-1)+1)
else:print((N-1)//(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())
data = list(map(int, input().split()))
print(math.ceil((n-1)/(k-1)))

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

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

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

min_idx = A.index(min(A))

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

Solution (Python):

import math
if __name__ == "__main__":
    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    print(int(math.ceil((n-k)/(k-1)))+1)

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

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

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

an = input()
an_list = an.split()
min = min(an_list)





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

print(res)

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 math
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
if k == len(nums):
    print(1)
else:
    print(math.ceil((n-1)/(k-1)))

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

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

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

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

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


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

Solution (Python):





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


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


data_list=list(A)

min_index=data_list.index(min(data_list))+1

anser=0

if (N-1) % (K-1) == 0:
	print((N-1)//(K-1))
else:
  	print((N-1)//(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):
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=(n-1)/(k-1)
if a!=int(a):
    print(int(a)+1)
else:
    print(int(a))

Solution (Python):
N,K=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
idx=A.index(1)
for i in range(2):
    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):



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

	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):
N,K = map(int,input().split())
A = list(input())
Ans = 0
 
if (N-1)%(K-1)==0:
    Ans = (N-1)//(K-1)
else:
    Ans = (N-1)//(K-1) + 1
 
print(Ans)

Solution (Python):
def Minimization(N,K,Alist):
    minindex = Alist.index(min(Alist))
    leftnum = minindex
    rightnum = N - (minindex + 1)
    print(-(-(leftnum+rightnum) // (K-1)))
N,K = list(map(int,input().split()))
Alist = input().split()
Alist = list(map(int,Alist))
Minimization(N,K,Alist)

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

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

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



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

F=0
for i in A:
    if i==1:
        X=F 
        Y=N-(F+1)
        break;
    F=F+1

P=(X+Y)//(K-1)
if (X+Y)%(K-1)>0:
    print(P+1)
else:
    print(P)

Solution (Python):


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




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

Solution (Python):
info = list(map(int, input().split(' ')))
array = list(map(int, input().split(' ')))

print((info[0]-1+info[1]-2)//(info[1]-1))

Solution (Python):
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
import math
print(math.ceil((len(a)-1)/(k-1)))

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

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

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

print(Ans)

Solution (Python):
import math
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
minIndex = A.index(min(A))
if K == len(A):
    print(1)
else:
    print(math.ceil((N-1)/(K-1)))

Solution (Python):
import math

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

res = math.ceil((N-1)/(K-1))

print(int(res))

Solution (Python):
n,k = (int(i) for i in input().split())
a = [int(i) for i in 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())
if k == 2:
    print(n-1)
elif k == n-1:
    print(2)
elif (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())
if k == 2:
    print(n-1)
elif k == n-1:
    print(2)
elif (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())
if k == 2:
    print(n-1)
elif k == n-1:
    print(2)
elif (n-k)%(k-1) == 0:
    print((n-k)//(k-1) +1)
else:
    print((n-k)//(k-1) + 2)

Solution (Python):
import sys

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

if ((n - 1) % (k - 1)) == 0:
    print((n - 1) // (k - 1))
    sys.exit()

pos = a.index(1)
start = 0
x = 0
if pos < k:
    start = k - 1
    x += 1
else:
    start = pos
    x += pos // (k - 1)
    if (pos % (k - 1)) != 0:
        x += 1

x += (n - (start + 1)) // (k - 1)
if ((n - (start + 1)) % (k - 1)) != 0:
    x += 1
print(x)

Solution (Python):
import math

s = input().rstrip().split()

n = int(s[0])
k = int(s[1]) - 1

a = input()

block = math.ceil(n / k)
if(k == 1):
  	print(n-1)

elif(n % k == 1):
    print(block - 1)
elif(n == k + 1):
    print(1)
else:
    print(block)

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

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

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

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

Solution (Python):
import math

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

count = A.index('1') + len(A)-A.index('1')-1
print(math.ceil(count/(K-1)))

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

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

Solution (Python):


inputN, inputK = map(int, input().split())
inputA = list(map(int, input().split()))
minNumber = inputN
minPos = 0

if inputN == inputK:
    print (1)
elif inputN <= (inputK-1)*100000 + 1:
    for i in range(2, 100001):
        if inputN <= (inputK-1)*i + 1:
            print (i)
            break
else:

    for i in range(len(inputA)):
        if inputA[i] < minNumber:
            minNumber = inputA[i]
            minPos = i

    splitNumber = (inputN + 1) / (inputK - 1)
    print (int(splitNumber))

Solution (Python):
tmp= input().rstrip().split(' ')
N=int(tmp[0])
K=int(tmp[1])

tmp= input().rstrip().split(' ')
L = tmp.index("1")

out = L//(K-1) + (N-1-L)//(K-1)

if(L%(K-1)>0):
    out+=1
if((N-1-L)%(K-1)>0):
    out+=1

if ((L%(K-1)==0) or ((N-1-L)%(K-1)==0)):
    pass
elif((L%(K-1) + (N-1-L)%(K-1)) <= (K-1)):
        out -=1
    
print(out)

Solution (Python):
import math
N,K = [int(i) for i in input().split()]
a = list(input().split())
m = a.index('1')
if m == 0 or m == N-1:
    print(math.ceil((N-1)/(K-1)))
else:
    res = ((K-1) - m%(K-1))%(K-1)
    print(math.ceil((m)/(K-1)) + math.ceil((N-m-1-res)/(K-1)))

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

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

min_A = min(A)


ind1 = A.index(1)
len1 = N -ind1
len2 = ind1 + 1

r1= 0
if (len1-1)%(K-1) != 0:
    r1 = 1

r2= 0
if (len2-1)%(K-1) != 0:
    r2 = 1
d = 0



ans1 = (len1-1)//(K-1)+r1 + (len2-1)//(K-1)+r2

ans=[]
ans.append(ans1)
for i in range(1, K):
    ans2 = 0
    r3= 0
    if (len1-i-1)%(K-1) != 0:
        r3 = 1

    r4= 0
    if (len2-((K-1)-i)-1)%(K-1) != 0:
        r4 = 1
    ans2 = (len1-i-1)//(K-1)+r3 + (len2-((K-1)-i)-1)//(K-1)+r4 + 1
    ans.append(ans2)



print(min(ans))

Solution (Python):
def m():
    def solve(n,k):
        if n <= k:
            return 1
        tmp = 1
        tmp += (n-k) // (k-1)
        if (n-k) % (k-1) == 0:
            return tmp
        return tmp + 1

    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    pos = a.index(1)
    ans = 1
    if pos <= (k-1) or pos >= (n-k):
        return solve(n,k)
    if (k % 2) == 0:
        div = k // 2
        left = a[:pos+(div-1)]
        right = a[pos+(div-1):]
    else:
        div = k // 2
        left = a[:pos+(div-1)]
        right = a[pos+(div):]
    ans += solve(len(left), k) + solve(len(right),k)
    return ans
print(m())

Solution (Python):
import math

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

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

Solution (Python):
a,b = [int(i) for i in input().split()]
A = list(map(int,input().split()))

if (a-1) % (b-1) == 0:
    print((a-1)//(b-1))
else:
    print((a-1)//(b-1)+1)

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


def retminvalue(syou):
    mini = 0
    mini += syou // (K-1)
    if(syou % (K-1) != 0):
        mini += 1
    return mini

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

if p == 0 or p==(N):
    print(retminvalue(N))
else:
    minlist = [99999 for i in range(K+3)]
    for i in range(K-1):
        minlist[i] =  retminvalue(N-p+i) + retminvalue(p-1-i)
    print(min(minlist))

Solution (Python):
import math

n, k = map(int, input().split())
nums = map(int, input().split())
ans = math.ceil((n-k) / (k-1)) + 1
print(ans)

Solution (Python):
"""
最小値で置き換えるなら全ての要素が等しくなったら全て最小値
8 3
k-1づつ隣に影響を及ぼせる
1の位置がiだとしたら(i-1)/(k-1)の切り上げと(N-i)/(k-1)の切り上げ
"""
import math

n , k = map(int, input().split())
b = list(map(int,input().split()))
cnt = 1
i = 0
for t in b:
    if t == 1:
        i = cnt
        break
    cnt += 1

result = math.ceil((i-1)/(k-1)) + math.ceil((n-i)/(k-1))
if ((i-1)/(k-1) - math.floor((i-1)/(k-1))) != 0 and ((n-i)/(k-1) - math.floor((n-i)/(k-1))) != 0 and (((i-1)/(k-1) - math.floor((i-1)/(k-1))) + ((n-i)/(k-1) - math.floor((n-i)/(k-1)))) <= 1:
    result -= 1

print(result)

Solution (Python):

import math

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

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

if n<= k:
	print 1
else:
	print int(math.ceil(float(n-k)/float(k-1))+1)

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 = list(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):
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):
a,b = map(int, input().split())
l = map(int, input().split())
c = b - 1
if a > b:
    d = 1
    while a > b:
        b += c
        d += 1
    print(d)
else:
    print(1)

Solution (Python):
N, k = map(int, input().split())
num = input().rstrip().split()

t = 0

for i in range(N):
  if num[i] == "1":
    one = i
    break
    
N -= 1


while(N > 0):
  N -= (k-1)
  t += 1



print(t)

Solution (Python):
str_n, str_k = input().split()
n = int(str_n)
k = int(str_k)
str_a = input().split()
a = [int(str) for str in str_a]

for i, num in enumerate(a):
    if num == 1:
        fir = i

left = fir
right = n - fir - 1

if k == 2:
    print(n - 1)
elif n == k:
    print(1)
else:
    print((n+k-3)//(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):
import math
N,K = [int(x) for x in input().split(" ")]
A =  [int(x) for x in input().split(" ")]
ans = math.ceil((N -1)/(K -1))
print(ans)

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

Solution (Python):
import numpy as np
listA=list(map(int,input().split()))
N=listA[0]
K=listA[1]
A=list(map(int,input().split()))
Anp=np.array(A)
if(N/K==1):
    print(1)
elif((N-1)%(K-1)==0):
    print(int((N-1)/(K-1)))
else:
    print(int((N-1)/(K-1))+1)

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

if N == K:
    ans = 1
else:
    ans = 1 + math.ceil((N-K)/(K-1))

print(ans)

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):
if __name__ == "__main__":
    NK = input().rstrip().split(' ')
    N = int(NK[0])
    K = int(NK[1])
    line = input().rstrip().split(' ')
    A = list(map(lambda x: int(x), line))
    
    
    
    if N == K:
        print("1")
        exit()
    right = 0
    left = N -1
    count = 0
    while True:
        right += (K-1)
        count += 1
        if right >= left:
            print(count)
            break
        left -= (K-1)
        count += 1
        if right >= left:
            print(count)
            break

Solution (Python):
import math
import sys
n, c = map(int, input().split())
if(n==c):
    print(1)
    sys.exit()
num = list(map(int, input().split()))
for i in range(len(num)):
    if num[i] == 1:
        first = i
        break
rightCount = math.ceil((n - first - 1) / (c - 1))
if((n - first - 1) % (c - 1) == 0):
    b = 0
else:
    b = c - 1 - ((n - first - 1) % (c - 1))

leftCount = math.ceil((first - b) / (c - 1))
print(leftCount + rightCount)

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

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

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

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

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

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

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

Solution (Python):

import math

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

if n == k:
    print(1)
else:
    print(math.ceil((n - 1) / (k - 1)))

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

min_index = 0
for index, i in enumerate(A):
    if i == 1:
        min_index = index
        break

if min_index == 0:
    left = 0
else:
    left = int((min_index + K - 2) / (K - 1))
    if min_index % (K - 1):
        add = (K - 1) - int(min_index % (K - 1))
        min_index += add
if min_index >= N - 1:
    right = 0
else:
    right = int((N - min_index + K - 3) / (K - 1))
ans = left + right

print(ans)

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

N = int(l[0])
K = int(l[1])

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

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

A = [int(i) for i in input().split(' ')]
"""
index_1 = -1

for i in range(len(A)):
    
    if A[i]==1:
        index_1 = i
        break

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

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

Solution (Python):
import sys


def func(N, K):
    if K == N:
        return 1
    elif K - 1 == 1:                                                                                                                                  
        return N - 1
    else:
        r = N // (K - 1)                                                                                                                              
        m = N % (K - 1)
        if m == 0 or m == 1:
            return r
        return r + 1

if __name__ == '__main__':
    N, K = map(int, sys.stdin.readline().split())
    A = map(int, sys.stdin.readline().split())
    print(func(N, K))

Solution (Python):
st = str(input())
tmp = st.split(" ")
N = int(tmp[0])
K = int(tmp[1])
y = str(input())
if N <= K:
    print(1)
else:
    x = 0
    if (N - K) % (K - 1) != 0:
        x = 1
    print(((N - K) // (K - 1) + x + 1))

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

answer=0
if N==K:
    print(1)
elif K!=2:
    if A.index(1)==0 or A.index(1)==N-1:
        if N-K>K:
            if (N-K)%(K-1) == 0:
                answer=int(1+((N-K)/(K-1)))
            else:
                answer=int(((N-K)/(K-1))+2)
        else:
            answer=2
        print(answer)
    else:
        left_items=A.index(1)
        right_items=(N-1)-A.index(1)
        if left_items<K or right_items<K:
            if (N-K)%(K-1) == 0:
                answer=int(1+((N-K)/(K-1)))
            else:
                answer=int(((N-K)/(K-1))+2)
            print(answer)

        left=left_items%(K-1)
        right=right_items%(K-1)
        if left+right+1 == K:
            answer=1+(int(left_items/(K-1))+int(right_items/(K-1)))
            print(answer)
        else:
            answer=1+(int(left_items/(K-1))+int(right_items/(K-1)))+1
elif K==2:
    answer=N-1
    print(answer)

Solution (Python):
import math
n,k=map(int,input().split())
l=list(map(int,input().split()))
count=0
num=1000000
mi=min(l[0:k])
if(mi<num):
    num=mi
for i in range(0,len(l),k-1):
    count+=1
    if(i<len(l)-1 and i+k-1>=len(l)):
        count+=1
        break
print(count-1)

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

i_1 = a.index(1)

ans = 9999999999

left = len(a[:i_1])
right = len(a[i_1:])

for i in range(k):
    x = left  - i
    y = right - (k-i)
    
    if x < 0 or y < 0:
        continue
    
    count = 1 + math.ceil(x/(k - 1)) + math.ceil(y/(k - 1))
    ans = min(ans,count)

print(ans)

Solution (Python):
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k = Is()
ls = Is()
_1 = ls.index(1)
ans = []
for i in range(_1-k+1,_1+k):
    ans.append(math.ceil(i/(k-1))+math.ceil((n-1-i)/(k-1)))
print(min(ans))

Solution (Python):
N, K = map(int, input().split())
l = input().split()
 
cnt=0
end_point=0 
for i,e in enumerate(l):
    if i !=end_point:
        continue 
    
    
    
    
    m= min(l[i:i+K])
    try:
        cnt =cnt+1
        for j in range(K):
            l[i+j]=m
        if i+j == len(l)-1:
            cnt=cnt-1
    except:
        print(cnt)
    end_point=i+j

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

Solution (Python):
N, M = map(int, raw_input().split())

a = []
a.append(map(int, raw_input().split()))

keylist = range(N)
colum = M
valuelist = a

A = {k: v for k, v in zip(keylist, valuelist)}


minkey = min(A, key = A.get)
minnum = min(A.values())

sum1 = 0

if minkey%(colum-1) != 0:
    sum1 = sum1 + (minkey//(colum-1))+1 
    
    
else:
    sum1 = sum1 + minkey//(colum-1)

num1 = N - minkey

if (num1-1)%(colum-1) != 0:
    sum1 = sum1 + ((num1-1)//(colum-1))+1
else: 
     sum1 = sum1 + (num1-1)//(colum-1)


print sum1

Solution (Python):
import math, sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]


n, k = LI()
a = LI()

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

print(result)