CodeEff/ECCO huggingface dataset:
# Original solution
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

def f():
  for i in range(1, N+1):
    if (K-1)*i + 1 >= N:
      return i
print((f()))

# Optimized solution
N,K = list(map(int, input().split()))

def f():
  for i in range(1, N+1):
    if (K-1)*i + 1 >= N:
      return i
print((f()))
# Original solution
#                         author:  kagemeka 
#                         created: 2019-11-08 13:38:56(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n, k, *a = (int(x) for x in sys.stdin.read().split())
    i = a.index(1)
    l = k - 1
    left, right = i, (n - 1) - i
    if left % l == 0:
        if right % l == 0:
            ans = left // l + right // l
        else:
            ans = left // l + right // l + 1
    else:
        if right % l  == 0:
            ans = left // l + 1 + right // l 
        else:
            if left % l + right % l > l:
                ans = left // l + right // l + 2
            else:
                ans = left // l + right // l + 1 
    
    print(ans)




if __name__ == "__main__":
    # execute only if run as a script
    main()


# Optimized solution
import sys

n, k, *a = list(map(int, sys.stdin.read().split()))

def main():
    return ((n - 1) + (k - 1) - 1) // (k - 1)

if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
import sys

n, k, *a = list(map(int, sys.stdin.read().split()))

def main():
    return ((n - 1) + (k - 1) - 1) // (k - 1)

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

# Optimized solution
import sys

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

def main():
    print(((n + k - 3) // (k - 1)))

if __name__ ==  '__main__':
    main()
# Original solution
def solve(array, k):
    ans = 0
    length = len(array)
    i = 0
    while i < length - 1:
        if array[i] == array[i + 1]:
            i += 1
        elif i + k >= length:
            ans += 1
            break
        else:
            ans += 1
            i += k - 1
            array[i] = min(array[:i + 1])
    return ans
    
if __name__ == "__main__":
    n, k = list(map(int, input().split()))
    array = [int(s) for s in input().split()]
    print((solve(array, k)))

# Optimized solution
def solve(n, k):
    div, mod = divmod(n - 1, k - 1)
    return div + (0 if mod == 0 else 1)

if __name__ == "__main__":
    n, k = list(map(int, input().split()))
    array = [int(s) for s in input().split()]
    print((solve(n, k)))
# Original solution
import math

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

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


# Optimized solution
N, K = list(map(int, input().split()))
print(((N-1)//(K-1)+bool((N-1)%(K-1))))
# Original solution
N,K = [int(i) for i in input().split()]
n = list(map(int, input().split()))
print(((N-K)//(K-1) + 1 if (N-K)%(K-1) ==0 else (N-K)//(K-1) + 2))


# Optimized solution
N,K = [int(i) for i in input().split()]
print(((N-K)//(K-1) + 1 if (N-K)%(K-1) == 0 else (N-K)//(K-1) + 2))
# Original solution
import math
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))

tmp = a.index(min(a))
amri = ((tmp) % (K - 1))
if amri == 0:
    ans = math.ceil(tmp / (K - 1)) + math.ceil((N - tmp - 1) / (K - 1))
else:
    ans = math.floor(tmp / (K - 1)) + math.ceil((N - tmp - (K- amri)) / (K - 1)) + 1
print(ans)

# Optimized solution
import math
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = math.ceil((N - 1)/ (K - 1))
print(ans)
# Original solution
def main():
    N, K = (int(i) for i in input().split())
    A = (int(i) for i in input().split())
    from math import ceil
    print((ceil((N-1)/(K-1))))
if __name__ == '__main__':
    main()

# Optimized solution
def main():
    N, K = (int(i) for i in input().split())
    from math import ceil
    print((ceil((N-1)/(K-1))))
if __name__ == '__main__':
    main()
# Original solution
import math
N, K = list(map(int, input().split()))
A = list(map(int, input().split())) #A[0]〜A[N-1]

m = min(A)
answer = N

for i in range(N-K+1): #A[i:i+K]〜A[N-K:N]
  if not m in A[i:i+K]:
    continue
  answer = min(answer,
              (1 + math.ceil(i/(K-1)) + math.ceil((N-K-i)/(K-1))))
print(answer)

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

print(((N-1)//(K-1) + bool((N-1)%(K-1))))
# Original solution
from sys import stdin
n, k, *a = list(map(int, stdin.read().split()))
print((((n - 1) + (k - 2)) // (k - 1)))


# Optimized solution
n, k = list(map(int, input().split()))
print((((n - 1) + (k - 2)) // (k - 1)))
# Original solution
N, K = list(map(int, input().strip().split()))
AList = list(map(int, input().strip().split()))

length = len(AList ) - 1
ans = 0
while(length > 0):
    ans += 1
    length = length - (K - 1)
print(ans)

# Optimized solution
N, K = list(map(int, input().strip().split()))
print((int((N- 1) / (K - 1)) + (0 if (N-1)%(K-1)==0 else 1)))
# Original solution
n,k = list(map(int,input().split()))
A = list(map(int, input().split()))

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


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

if (n-1)%(k-1) != 0:
  cnt = (n-1)//(k-1)+1
else:
  cnt = (n-1)//(k-1)
  
print(cnt)
# Original solution
#!/usr/bin/env python3
import sys
import math

def solve(N: int, K: int, A: "List[int]"):
    ix = A.index(1)

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


    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
import math

def solve(N: int, K: int, A: "List[int]"):

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

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

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

if k < n:
    c = 1
    n -= k
    while n > 0:
        n -= k-1
        c += 1
    print(c)
else:
    print((1))

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

if k < n:
    c = 1
    n -= k
    c += -((-n)//(k-1))
    print(c)
else:
    print((1))
# Original solution
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

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

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

# 結果出力
print(ans)

# Optimized solution
# -*- coding: utf-8 -*-
# モジュールのインポート
import math


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    # 標準入力を取得
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    return N, K, A


def main(N: int, K: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 数列の長さ(2 <= K <= N <= 10**5)
        K (int): 選択する要素数(2 <= K <= N <= 10**5)
    """
    # 求解処理
    ans = math.ceil((N - 1) / (K - 1))

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, K, A = get_input()

    # メイン処理
    main(N, K)
# Original solution
import math
def resolve():
	n, k = list(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()

# Optimized solution
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)

def resolve():
	n, k = list(map(int, input().split()))
	a = list(map(int, input().split()))
	v = math.ceil((n - k) / (k-1) + 1)
	print(v)
resolve()
# Original solution
def solve():
    n,k = list(map(int, input().split()))
    A = list(map(int, input().split()))
    if (n-1)%(k-1) != 0:
        return (n-1)//(k-1) + 1
    else:
        return (n-1)//(k-1)

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

# Optimized solution
def solve():
    n,k = list(map(int, input().split()))
    if (n-1)%(k-1) != 0:
        return (n-1)//(k-1) + 1
    else:
        return (n-1)//(k-1)

if __name__ == '__main__':
    print((solve()))
# Original solution
N, K = list(map(int, input().split(" ")))
lista = list(map(int, input().split(" ")))
num = 0
listlist = []
listlist.append(lista)
r = len(lista) - K + 1
while(True):
    num += 1
    newlistlist = []
    for tmplist in listlist:
        for i in range(r):
            tmptmplist = tmplist.copy()
            m = min(tmptmplist[i:i+K])
            for j in range(K):
                tmptmplist[i + j] = m
            newlistlist.append(tmptmplist)
    mm = min([len(set(listb)) for listb in newlistlist])
    if mm == 1:
        break
    listlist = newlistlist
print(num)

# Optimized solution
N, K = list(map(int, input().split(" ")))
lista = list(map(int, input().split(" ")))
num = 0
listlist = []
listlist.append(lista)
r = len(lista) - K + 1
m = min(lista)
while(True):
    num += 1
    newlistlist = []
    for tmplist in listlist:
        for i in range(r):
            tmptmplist = tmplist.copy()
            if min(tmptmplist[i:i+K]) == m:
                for j in range(K):
                    tmptmplist[i + j] = m
                newlistlist.append(tmptmplist)
    mm = min([sum(listb) for listb in newlistlist])
    if mm == m * N:
        break
    listlist = newlistlist
print(num)
# Original solution
n, k = list(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)

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

ans = -((-n + 1) // (k - 1))
print(ans)
# Original solution
A, B = list(map(int, input().split()))
target_list = input().split()

def check_list(lis):
    # print(lis)
    return len(list(set(target_list))) == 1

count = 0
while check_list(target_list) == False:
    min_in_list = min(target_list)
    tmp = A - 1 
    while((target_list[tmp] != min_in_list) or (target_list[tmp] == target_list[tmp-1])):
        tmp -= 1
    min_pos = tmp
    if(min_pos - B) >= 0:
        for i in range(min_pos-(B-1), min_pos):
            target_list[i] = min_in_list
    else:
        for i in range(0, min_pos+1):
            target_list[i] = min_in_list
        for i in range(A-(B-min_pos-1), A):
            target_list[i] = min_in_list

    count += 1

print(count)



# Optimized solution
import math
i, j = list(map(int, input().split()))
target_list = list(map(int, input().split()))
print((math.ceil((i-1)/(j-1))))
# Original solution
import math

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

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

print(ans)


# Optimized solution
import math

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

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

print(ans)
# Original solution
import bisect

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

amin=min(a)
m=bisect.bisect(a,amin)

for i in range(n):
    if a[i]==1:
        m=i+1
        

k1=k-1
#print(m,k1)

if k1==1:
    print((n-1))
else:
    if m==0:
        n2=(n-1)//k1+1
        print(n2)
    elif m==n:
        n2=(n-1)//k1+1
        print(n2)
    else:
        n2=(m-1-1)//k1+1
        n2r=(n2)*k1-(m-1)
        n3=(n-m-1-n2r)//k1+1
#        print("n",n,"m",m,"k1",k1,"n2",n2,"n3",n3)
        print((n2+n3))

# Optimized solution

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

print(((n-2)//(k-1)+1))
# Original solution
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

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


# Optimized solution
N, K, *A = list(map(int, open(0).read().split()))
print((-(-(N - 1) // (K - 1))))
# Original solution
N, K, *A = list(map(int, open(0).read().split()))
print((-(-(N - 1) // (K - 1))))


# Optimized solution
N, K = list(map(int, input().split()))
print((-(-(N - 1) // (K - 1))))
# Original solution
import math
N, K = list(map(int, input().split()))
A_list = [int(i) for i in input().split()]

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

# Optimized solution
import math
N, K = list(map(int, input().split()))
print((math.ceil((N-1)/(K-1))))
# Original solution
N,K=list(map(int,input().strip().split()))
A=list(map(int,input().strip().split()))

i=A.index(1)+1
if i<=K or i>=N-K:
    ans=(N-K)//(K-1)+1 if (N-K)%(K-1)==0 else (N-K)//(K-1)+2
else:
    for a in range(K):
        if (i-a)%(K-1)==0 and (N-(i+(K-a)))%(K-1)==0:
            b=0
        else:
            b=1
    front=i//(K-1)
    back=(N-(i+K))//(K-1)
    ans=front+back+1+b
print(ans)

# Optimized solution
N,K=list(map(int,input().strip().split()))
A=list(map(int,input().strip().split()))

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


# Optimized solution
from math import ceil
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = ceil((N-1)/(K-1))
print(ans)
# Original solution
# -*- coding:utf-8 -*-
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
min = n
range_value = one_index if k > one_index else k
for i in range(range_value+1):
    left = one_index - k + i + 1
    right = len(nums[one_index+1:]) - i
    if left + right > n-1:
        break
    else:
        min_tmp = (-(-left//(k-1)))+(-(-right//(k-1)))+1
        if min > min_tmp:
            min = min_tmp
print(min)


# Optimized solution
# -*- coding:utf-8 -*-
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))))
# Original solution
'''WA
N,K=map(int,input().split())
A=list(map(int,input().split()))
x=A.index(1)
K-=1
print((x-1)//K+(N-x-2)//K+2)
'''
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
cnt=0
while 1:
    idx=A.index(1)
    if idx==0:break
    if idx+1<=K:
        A[:K]=[1]*K
    else:
        A[idx-K+1:idx+1]=[1]*K
    cnt+=1
A=A[::-1]
while 1:
    idx=A.index(1)
    if idx==0:break
    if idx+1<=K:
        A[:K]=[1]*K
    else:
        A[idx-K+1:idx+1]=[1]*K
    cnt+=1
print(cnt)

# Optimized solution
N,K=list(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)
# Original solution
N, K = list(map(int, input().split()))
A = [int(x) for x in input().split()]
minIndex = [i for i, x in enumerate(A) if x == min(A)]
print(((minIndex[0]+1)//K+(len(A)-max(minIndex[0], 1))//K+1))


# Optimized solution
import math
N, K = list(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))))
# Original solution
n,k = list(map(int, input().split()))

x=(n-k)//(k-1)
y=(n-k)%(k-1)

if y==0:
    print((x+1))
else:
    print((x+2))

# Optimized solution
n,k = map(int, input().split())
x=(n-k)//(k-1)
y=(n-k)%(k-1)
print(x+1) if y==0 else print(x+2)
# Original solution
n,k = list(map(int,input().split()))
lst = list(map(int,input().split()))

id = lst.index(1)

left = len(lst[0:id])
right = len(lst[id+1:])
mod = max(left%(k-1),right%(k-1))

total = left + right

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

print(counter)

# Optimized solution
n,k = list(map(int,input().split()))
lst = list(map(int,input().split()))

id_of_one = lst.index(1) #リスト内の最小値1のインデックスを取得

left = len(lst[0:id_of_one]) #1より左側にある数列の長さ
right = len(lst[id_of_one+1:]) #1より右側にある数列の長さ
total = left + right





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

print(counter)
# Original solution
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

now = k
res = 1
while now < n:
    now += k-1
    res += 1

print(res)

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

if (n + k - 1) // k == 1:
    print((1))
else:
    res = ((n - k) + (k - 2)) // (k - 1) + 1
    print(res)
# Original solution
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
if n==k:
    print((1))
    exit()
i=n-k
ans=1
while i>0:
    i=i-k+1
    ans+=1
print(ans)

# Optimized solution
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
print((-(-(n-k)//(k-1))+1))
# Original solution
import math
N, K = list([int(k) for k in input().split(" ")])
A = list([int(a) for a in input().split(" ")])

pos_of_1 = A.index(1)

if K >= pos_of_1 + 1 or N - K <= pos_of_1:
  print((math.ceil((N - K) / (K - 1)) + 1)) 
else:
  L = A[:pos_of_1 + 1]
  R = A[pos_of_1:]
  res = []
  for i in range(1, K):
    l = math.ceil((len(L) - i) / (K - 1)) + 1
    r = math.ceil((len(R) - K - 1 + i) / (K - 1)) + 1
    res.append(l + r - 1)
  print((min(res)))

# Optimized solution
import math
N, K = list([int(k) for k in input().split(" ")])
A = list([int(a) for a in input().split(" ")])

print((math.ceil((N - K) / (K - 1)) + 1))
# Original solution
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
print((-(-(N-1)//(K-1))))

# Optimized solution
N,K = list(map(int,input().split()))
print((-((1-N)//(K-1))))
# Original solution
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
print((-((1-n)//(k-1))))

# Optimized solution
print((eval("-(-~-"+input().replace(" ","//~-")+")")))
# Original solution
import math

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


def main():
    print((math.ceil((N - 1) / (K - 1))))
    return


main()


# Optimized solution
def main():
    N, K = list(map(int, input().split()))
    print((-(-(N - 1) // (K - 1))))
    return


main()
# Original solution
n,k = list(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))

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


# Optimized solution
N, K = list(map(int, input().split()))
print((-(-(N - 1) // (K - 1))))
# Original solution
import math
n,k = list(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+1:)

# if left < k or right <k:
#     c = math.ce

for i in range(1,k+1):
    count = 1
    left = i_1-(k-i)
    right = i_1+i

    if left < 0 or right < 0:
        continue


    l_l = len(a[:left])
    r_l = len(a[right:])

    count += math.ceil(l_l / (k-1)) + math.ceil(r_l / (k-1))
    ans = min(count,ans)

print(ans)

# Optimized solution
import math
n,k = list(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)
# Original solution
# AtCoder Beginner Contest 101
# C - Minimization

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

# Optimized solution
# AtCoder Beginner Contest 101
# C - Minimization

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