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):
n,k = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

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

print(cnt)

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

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

for i in range(N):
    if A[i] == 1:
        ans = N
        for j in range(max(0, i-(K-1)), min(N, i+K-1)):
            ans = min(math.ceil(j/(K-1)) + math.ceil((N-j-1)/(K-1)), ans)
        break
print(ans)

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

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

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

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

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

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

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

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=list(map(int,input().split()))
ans=math.ceil((n-1)/(k-1))
print(ans)

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

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

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

Solution (Python):
print(eval('0--~-'+''.join([i if i!=' 'else'//~-'for i in input()])))

Solution (Python):
print(eval('0--~-'+''.join([i if i!=' ' else '//~-' for i in input()])))

Solution (Python):
print(eval('0--~-'+input().replace(' ','//~-')))

Solution (Python):
a=input().split();print(0--~-int(a[0])//~-int(a[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());print(0--~-n//~-k)

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

Solution (Python):
n,k,*_=map(int,open(0).read().split())
print(0--~-n//~-k)

Solution (Python):

"""
Created on Fri Sep 18 09:56:28 2020

@author: liang
"""
from math import ceil

N, K = map(int, input().split())
A = [int(x) for x in input().split()]
ans = ceil((N-K)/(K-1)) + 1
print(ans)

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

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

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

Solution (Python):

import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)

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

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


if __name__ == '__main__':
    main()

Solution (Python):


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)

Solution (Python):


import math


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


ans = math.ceil((N - 1) / (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):
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())
print(((N - 1) + (K - 2)) // (K - 1))

Solution (Python):


import math


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


x = A.index(1)
y = N - x - 1
ans = math.ceil(x / (K - 1))
if x % (K - 1) != 0:
    y -= K - 1 - (x % (K - 1))
ans += math.ceil(y / (K - 1))


print(ans)

Solution (Python):
import math

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

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

print(C+1)

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

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

Solution (Python):
import math

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

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

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

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

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

    tmp = k
    count = 1
    while tmp < n:
        tmp += k - 1
        count += 1

    print(count)


if __name__ == '__main__':
    main()

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

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

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


def get_1_index(a):
    for i,j in enumerate(a):
        if j==1:
            return i


index=get_1_index(a)

mae=index
usiro=n-index-1


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

Solution (Python):
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    if K == 2:
        print(N - 1)
    else:
        ans = 10**10
        for k in range(K):
            v = 0
            if k > 0:
                v += 1
            v += (N - k) // (K - 1)
            if (N - k) % (K - 1) > 1:
                v += 1
            if v < ans:
                ans = v
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array
import numpy as np





sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    A = il()

    ret = 1
    N -= K
    while not N <= 0:
        N -= K - 1
        ret += 1
    print(ret)


if __name__ == '__main__':
    main()

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

print(c+1)

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

Solution (Python):
n,k = map(int,input().split())
a = list(map(int,input().split()))
p = min(a)
a += [p]
ans,i,temp = 0,0,0
while i<n:
  if a[i]==p:
    m = -(-(i-temp)//(k-1))
    ans += m
    temp += m*(k-1)+1
    i = temp
  else:
    i += 1
ans += -(-(n-temp)//(k-1))
print(ans)

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

for i_1 in range(n):
    if a[i_1]==1:
        break



if len(a[:i_1])==0:
    ans = len(a[i_1+1:])//(k-1)
    if len(a[i_1+1:])%(k-1)==0:
        print(ans)
    else:
        print(ans+1)
elif len(a[i_1+1:])==0:
    ans = len(a[:i_1])//(k-1)
    if len(a[:i_1])%(k-1)==0:
        print(ans)
    else:
        print(ans+1)
else:
    ans = len(a[:i_1])//(k-1) + 1
    tmp = ans * (k-1)
    ans += len(a[tmp+1:])//(k-1)
    if len(a[tmp+1:])%(k-1)==0:
        print(ans)
    else:
        print(ans+1)

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

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

argmin = A.index(1)

back = (argmin+(K-1)-1)//(K-1)
forward = (N-argmin-1+(K-1)-1)//(K-1)
ans1 = back+forward

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

print(min(ans1,ans2))

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

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

m = a.index(1)
print(ceil((n-1)/(k-1)))

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

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

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

count =0
first = True
while N >=K:
    if  first ==True:
        count +=1
        N-=K
        first =False
        
    else:
        count+=1
        N-=(K-1)
        
   
    

if N!=0:
    count+=1
print(count)

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

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

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

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]







n,k = MI()
a = RI()


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

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]







n,k = MI()
a = RI()

ind = a.index(1)
ans = INF

if ind>(k-1) and ind<(n-k):
    for i in range(ind-k+1,ind+k):
        
        m = 0
        m += ceil(i/(k-1))
        m += ceil((n-i-1)/(k-1))
        ans = min(ans,m)
        
elif ind<=(k-1):
    ans = 0
    ans += ceil((n-k)/(k-1)) + 1
else:
    ans = 0
    ans += ceil((n-k)/(k-1)) + 1

print(ans)

Solution (Python):
n, k = 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)

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

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

print(res)

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

i = a.index(1)

s = n

for j in range(i-k+1, i+k):
    if j < 0:
        continue
    elif j >= n:
        continue
    else:
        l = j
        u = (n-1-j)
        t = (l+k-2) // (k-1) + (u+k-2) // (k-1)
        
        s = min(s, t)

print(s)

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

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

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

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

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

ans = 1
ref = K
while ref < N:
    ans += 1
    ref += K-1

print(ans)

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

Solution (Python):
def waru(a,b):
  if a%b==0:
    return a//b
  else:
    return (a//b)+1
N,K=map(int,input().split())
L=list(map(int,input().split()))
mina=min(L)
ind=list()
R=[0]*N
for i in range(N):
  if L[i]==mina:
    ind.append(i)
    R[i]+=1
for i in range(1,N):
  R[i]=R[i-1]+R[i]
s=ind[0]
a=waru(s,K-1)
b=(a*(K-1))-s
susumi=b+s+1

while True:
  if susumi>=N:
    print(a)
    break
  if R[min(susumi+K,N-1)]-R[susumi]>0:
    susumi+=K
    a+=1
  else:
    susumi+=K-1
    a+=1

Solution (Python):
from math import ceil

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

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


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

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

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

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

Solution (Python):
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(100000):
  if N<=K+i*(K-1) :
    print(i+1)
    exit()

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, k = nm()
    A = nl()
    print((n - 1) // (k - 1) if (n - 1) %
          (k - 1) == 0 else (n - 1) // (k - 1) + 1)


if __name__ == '__main__':
    main()

Solution (Python):
import math


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


if __name__ == "__main__":
    main()

Solution (Python):
import math


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


if __name__ == "__main__":
    main()

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


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 math

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

p = 0
for i in range(n):
    if aa[i] == 1:
        p = i
        break

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *A = map(int, read().split())

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

    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *A = map(int, read().split())

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

    return


if __name__ == '__main__':
    main()

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

Solution (Python):

import math

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

index = a.index(1)

pre = index
post = n-index-1

ans = 10**10
for i in range(0, k):
    ans_tmp = 0
    pre_tmp = max(0, pre-i)
    post_tmp = max(0, post-(k-1-i))
    ans_tmp += math.ceil(pre_tmp/(k-1))
    ans_tmp += math.ceil(post_tmp/(k-1))
    ans = min(ans, ans_tmp)
    

print(ans+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()))
import math
ans = math.ceil((n - 1) / (k - 1))
print(ans)

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

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

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

Solution (Python):
import math

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

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

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter



import bisect
n,k=map(int,input().split())
a=list(map(int,input().split()))
ix=a.index(1)
i=math.ceil((n-k)/(k-1))+1
print(i)

Solution (Python):
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
divide_number = K - 1
other_number = N - 1
answer = 0
answer = other_number // divide_number
if other_number % divide_number != 0:
    answer += 1
print(answer)

Solution (Python):
n,k=(int(i) for i in input().strip().split(" "))
ar=[int(i) for i in input().strip().split(" ")]
from math import ceil
pos=ar.index(1)
a=n-1-pos
b=pos
a1=(a//(k-1))
a2=b//(k-1)
c=ceil((n-1-((a1+a2)*(k-1)))/(k-1))
print(a1+a2+c)

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

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

if n==k:
    print(1)
    exit()
    
x = 1+(n-k)//(k-1)
y = (n-k)%(k-1)

if y >0:
    print(x+1)
else:
    print(x)

Solution (Python):

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

ans=0
i=0
while i<n-1:
  ans=ans+1
  i=i+k-1
  
  
print(ans)

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))
t = A.index(1)
ans = 10 ** 7
for i in range(K):
    pre = max(t + i, 0)
    tail = max(N - 1 - t - i, 0)
    unit = K - 1
    pre_unit = -(-pre // unit)
    tail_unit = -(-tail // unit)
    ans = min(ans, pre_unit + tail_unit)
print(ans)

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

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

Solution (Python):
k,n=map(int,input().split())
a=input()
i=0
while True:
    if k<=n+(n-1)*i:print(i+1);break
    i+=1

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

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

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

Solution (Python):
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  

N,K = MI()
A = LI()

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

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left, bisect_right 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

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

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

Solution (Python):
import sys
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 = [int(i) for i in input().split()]

b = a.index(1) 
ans = 0
b -= (k-1)
if b < 0:
    b = a.index(1) + abs(b)
if b > n-1 -(k-1):
    b -= b- (k-1)
c,d = divmod(b,k-1)
ans += c
if d != 0:
    ans +=1
e,f = divmod(n-1 - b,k-1)
ans += e
if f != 0:
    ans +=1
if d != 0 and f != 0 and d + f <= k-1:
    ans -=1
print(ans)

Solution (Python):
import math

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

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


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

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

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

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

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

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

Solution (Python):
NK = list(map(int,input().split()))
A = list(map(int,input().split()))
N = NK[0]
K = NK[1]

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

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

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

Solution (Python):
N,K = (int(X) for X in input().split())
A  = [int(X) for X in input().split()]
Left  = A.index(1)
Right = (N-1)-Left
Count = (Right%(K-1)!=0)+Right//(K-1)
Left -= ((K-1)-Right%(K-1))%(K-1)
Count += (Left%(K-1)!=0)+Left//(K-1)
print(Count)

Solution (Python):
N,K = (int(X) for X in input().split())
A  = [int(X) for X in input().split()]
Left  = A.index(1)
Right = (N-1)-Left
Count = (Right%(K-1)!=0)+Right//(K-1)
Left  -= (Right%(K-1)!=0)*((K-1)-Right%(K-1))
Count += (Left%(K-1)!=0)+Left//(K-1)
print(Count)

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

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


ans = 0
i = 0

while True:
    if i*(K-1) >= N-1:
        break
    ans += 1
    i += 1
    
print(ans)

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

Solution (Python):
N,K=map(int,input().split())
A=list(map(int,input().split()))
if N<=K:
  print(1)
else:
  i=K
  a=1
  while i<N:
    i+=(K-1)
    a+=1
  print(a)

Solution (Python):
n, k = [ int(i) for i in input().split(' ') ]
xs = [ int(x) for x in input().split(' ') ]
i0 = xs.index(min(xs))
print(1 + min([ (i + k - 2) // (k - 1) + (n - i - 2) // (k - 1)
  for i in range(max(i0 - k + 1, 0), min(i0, n - k) + 1) ]))

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

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

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

Solution (Python):
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
m = a.index(1)
ans = 9999999999
left = len(a[:m])
right = len(a[m:])
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):
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==k):
    print(1)
else:
    print(1+(n-k-1)//(k-1)+1)