Problem:
 Score : 300 points    Problem Statement There is a sequence of length N : A_1, A_2, ..., A_N . Initially, this sequence is a permutation of 1, 2, ..., N .  On this sequence, Snuke can perform the following operation:   Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.   Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.
Find the minimum number of operations required.
It can be proved that, Under the constraints of this problem, this objective is always achievable.      Constraints  2 \leq K \leq N \leq 100000  A_1, A_2, ..., A_N is a permutation of 1, 2, ..., N .         Input Input is given from Standard Input in the following format:  N  K  A_1  A_2  ...  A_N       Output Print the minimum number of operations required.        Sample Input 1 4 3
2 3 1 4      Sample Output 1 2  One optimal strategy is as follows:    In the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4 .    In the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1 .         Sample Input 2 3 3
1 2 3      Sample Output 2 1       Sample Input 3 8 3
7 3 1 8 4 6 2 5      Sample Output 3 4

Solution (Python):
































import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

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

if N == K:
    print(1)
    exit()
result = 0
N -= K
result += 1
result += N / (K-1)
if N % (K-1) != 0:
    result = int(result) + 1

print(int(result))

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

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

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

print(int(result))

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

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

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

start = A.index(1)
d1 = start - 0
d2 = N-1 - start
n = 0
m = 0
print(fractions.math.ceil((len(A)-1)/(K-1)))

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

Solution (Python):


"""
Created on 2019/3/16
Solved on 2019/3/
@author: shinjisu
"""






def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n 

def getIntMat(n, m):  
    
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N, K = getIntList()
    d.dmp((N, K))
    A = getIntList()
    d.dmp(A)
    count = (N-1+K-2)//(K-1)
    return count


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

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

idx = 0
for i, a in enumerate(Ai):
    if a == 1:
        idx = i
        break
K2 = K - 1
left_num = idx
left_count = left_num // K2
if left_num % K2 > 0:
    left_count += 1

right_idx = K2 * (left_count - 1) + K

right_num = N - right_idx
right_count = right_num // K2
if right_num % K2 > 0:
    right_count += 1

print(left_count + right_count)

Solution (Python):
import sys
input = sys.stdin.readline

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

res = 1
cnt = k

if n <= cnt:
    print(res)
else:
    if (n-k)%(k-1) == 0:
        print(1 + (n-k)//(k-1))
    else:
        print(1 + (n-k)//(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-1)/(K-1)))

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

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

min_v = min(l)

min_idx = []

for i in range(n):
    if l[i] == min_v:
        min_idx.append(i)

tail = 0

curr_min = 0
pre_min_idx = 0
res = 0
idx = min_idx[0]
i = 0
while tail < n:
    for i in range(tail,n):
        if l[i]==min_v:
            idx = i
            break
    if idx != i:
        res += (n-tail)//(k-1) + (not not (n-tail)%(k-1)) 
        break
    interval = idx - tail
    num = interval//(k-1)
    delta = not not interval%(k-1)
    res += num+delta
    
    tail += (num+delta)*(k-1)+1
    
print(res)

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

print( 1 + math.ceil((n-k) / (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):
import math as ma
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(ma.ceil((N-K)/(K-1))+1)

Solution (Python):
from math import ceil


def solve(string):
    n, k, *a = map(int, string.split())
    return str(ceil((n - 1) / (k - 1)))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))

Solution (Python):
import math

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


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


main()

Solution (Python):
input = open(0).read

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


def main():
    num = (N - 1) / (K - 1)
    print(int(num) + 1 if num != int(num) else int(num))
    return


main()

Solution (Python):
import math

input = open(0).read

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


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


main()

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

Solution (Python):
from sys import stdin
import math
N, K = map(int, input().split())
a = [int(x) for x in stdin.readline().rstrip().split()]

N = N - K
cnt = 1

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

Solution (Python):
from math import ceil


def minimization(N: int, K: int, A: list) -> int:
    return 1 + ceil((N - K) / (K - 1))


if __name__ == "__main__":
    N, K = map(int, input().split())
    A = [int(s) for s in input().split()]
    ans = minimization(N, K, A)
    print(ans)

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

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

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

Solution (Python):
import numpy as np

def f(m,n):
    ret=m/n
    ret_=int(ret)
    if ret_==ret:
        return ret_
    else:
        return ret_+1
      
N,K=list(map(int,input().split()))
a=np.array(list(map(int,input().split())))
print(f(np.sum(a!=min(a)),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):
N,K=map(int,input().split())
L=list(map(int,input().split()))

for i in range(N):
  if L[i]==1:
    base=i//(K-1)+(N-i-1)//(K-1)
    modulo=i%(K-1)+(N-i-1)%(K-1)

if modulo==0:
  print(base)
elif 1<= modulo < K:
  print(base+1)
else:
  print(base+2)

Solution (Python):


import sys 
import math

n,k = map(int, input().split())
input()
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-2))//(K-1))

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

a.sort()
num = a.count(a[0])

answer = math.ceil((len(a) - num)/ (k-1))
print(answer)

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()))
for i in range(len(a)):
    if a[i]==1:
        p=i+1
        break
ans=0
ans+=p//(k-1)+1
right=n-(i+1)-(k-(i+1)%(k-1))
ans+=-(-right//(k-1))
print(ans)

Solution (Python):


















import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

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

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

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

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

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_arr = list(map(int, input().split()))

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

Solution (Python):
import math

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

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

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

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

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

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

print(ans)

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

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

Solution (Python):
import sys

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


if __name__ == '__main__':
  main()

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

A = len(A)
a = 0
l_s = N_K[1]
l = 0
for i in range(N_K[0]):
    
    if l>=N_K[0]:
        print(a)
        
        break
    a = a+1
    l = l + l_s
    if l > l_s:
        l -= 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()))

for i in range(1,10**5+1):
    if i >= (N-K)/(K-1) + 1:
        print(i)
        exit()

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

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

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

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

i = 0

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

print(i)

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

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

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

Solution (Python):

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

Solution (Python):
import numpy
n,r=map(int,input().split())
l=list(map(int,input().split()))
ans=numpy.ceil((n-1)/(r-1))
print(int(ans))

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

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

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

if n==k:
    print(1)
else:
    n-=k
    count+=1
    while(n>=k):
        n-=(k-1)
        count+=1
    print(count+1)

Solution (Python):
from math import ceil


class Solver(object):
    def __init__(self):
        self.n, self.k = list(map(int, input().split(" ")))
        self.a_s = list(map(int, input().split(" ")))

    def solve(self):
        print(ceil((self.n-self.k) / (self.k-1)) + 1)


if __name__ == "__main__":
    s = Solver()
    s.solve()

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

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

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

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())
a = list(map(int,input().split()))

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

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

noMinLen = len(Alist) - Alist.count(min(Alist))
result = noMinLen / (K-1)

if result > noMinLen // (K-1):
    result = (noMinLen // (K-1)) + 1

print(int(result))

Solution (Python):
N ,K = map(int,input().split())
L = list(map(int,input().split()))
def ceil(x):
    if x == int(x):
        return x
    else:
        return int(x) + 1


cnt = 0

N = N - K 
cnt += 1
if N > 0:
    cnt += ceil(N / (K-1))
print(int(cnt))

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

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

Solution (Python):
import math


def solve(N, K, As):
    ans = 1
    N = N - K
    return ans + math.ceil(N / (K - 1))


if __name__ == "__main__":
    N, K = map(int, input().split(" "))
    As = list(map(int, input().split(" ")))
    print(solve(N, K, As))

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

Solution (Python):
n,k = map(int, input().split())
a  = [int(i) for i in 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()))
ans = (n-1) / (k-1)
print(math.ceil(ans))

Solution (Python):

import sys



def solve(lines):
    N,K = map(int, lines.pop(0).split(' '))
    A = list(map(int, lines.pop(0).split(' ')))
    min_a = min(A)
    idx = 0
    re = 0
    while( idx < N - 1):
        if ( all([i == min_a for i in A[idx:idx+K] ]) ):
            idx += K - 1
            continue
        else:
            re += 1
            idx += K - 1
    print(re)

















lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

Solution (Python):



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

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

Solution (Python):



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

Solution (Python):
[print(int((n[0] - 2) / (n[1] - 1) + 1)) for n in [list(map(int, input().split()))]]

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

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

Solution (Python):
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    minA = min(A)
    if (N - A.count(minA)) % (K - 1) == 0:
        print((N - A.count(minA)) // (K - 1))
    else:
        print((N - A.count(minA)) // (K - 1) + 1)


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

min_idx = A.index(min(A))

count = N
start = max(0,min_idx-K+1)
end = min(start+K, N)
for i in range(start, end):
    tmp = math.ceil(i/(K-1)) + max(0, math.ceil((N-(i+K))/(K-1)))
    if count > tmp+1:
        count = tmp+1

print(count)

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

Solution (Python):



def main():
    from math import ceil

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

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


if __name__ == '__main__':
    main()

Solution (Python):
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
i = A.index(1)
l, r = i, N-i-1
div = [[j, K-1-j] for j in range(K)]
minval = 10000000
for d in div:
    if l-d[0] >= 0 and r-d[1] >= 0:
        minval = min(minval, ceil((l-d[0])/(K-1)) + ceil((r-d[1])/(K-1)) + 1)
print(minval)

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

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

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

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

Solution (Python):

import math

def main():
    na = list(map(int, input().split()))
    N, K = na[0], na[1]
    A = list(map(int, input().split()))

    i1 = A.index(1)
    r = math.ceil((N - 1) / (K - 1))

    print(r)


if __name__ == '__main__':
    main()

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

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

if N <= K:
    print(ans)
else:
    while num < N:
        num += K-1
        ans += 1
    print(ans)

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

while n>1:
  n=n-k
  n=n+1
  count=count+1
  
print(str(count))

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

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

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

print(ans)

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

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

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

Solution (Python):
N,K = [int(s) for s in input().split()]
data = [int(s) for s in input().split()]
i = 1
while True:
    if (K-1)*i + 1 >= N:
        print(i)
        exit()
    else:
        i += 1

Solution (Python):
N,K = map(int,input().split())
series = list(map(int,input().split()))
onepoint=series.index(1)
start = max(0,onepoint-K+1)
end = min(len(series),onepoint+K)

ans = 10**9
for p in range(start,end):
	tmp = 0
	back = p
	front = p + K
	
	
	tmp += -(-back // (K-1)) 
	tmp += -(-(len(series)-front) // (K-1))
	
	if ans > tmp:
		ans = tmp

print(ans+1)

Solution (Python):
from math import *
N, K = [int(x) for x in input().strip().split()]
print(ceil((N-1)/(K-1)))

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

Solution (Python):
from collections import Counter
from math import *
N, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
A.sort()
c = Counter(A)
minc = c[A[0]]
res = len(A) - minc
print(ceil(res/(K-1)))

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

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

N = int(N)
K = int(K)

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

count = 1

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

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

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

print(ans)

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

Solution (Python):
n, k = map(int, input().split())
A_list = list(map(int, input().split()))
def ceiling(n,div):
    return n // div + int(n % div != 0)
count = ceiling(n-1,k-1)
print(count)

Solution (Python):
import math

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

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

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

n -= k
count = 1

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

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

for i in A:
    if i == 1:
        count += 1
        
if (n - k * count) % (k - 1)  != 0:
    ans =count +  (n - k * count) // (k - 1) + 1
else:
    ans = count + (n - k * count) // (k - 1) 

print(ans)

Solution (Python):
def main():
    n, k = map(int, input().split())
    aa = list(map(int, input().split()))
    m = aa.index(1) + 1
    i = 0
    c = 0
    while i < m:
        if i == 0:
            i += k
        else:
            i += (k - 1)
        c += 1
    r = max(n - i, 0)
    c += r // (k - 1) + int(r % (k - 1) != 0)
    print(c)


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
a,b = map(int,input().split(" "))
ar = 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 = map(int,input().split())
a_list = 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()))


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

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

i=1
if n % k ==0:
  print(n//(k-1))
  exit()
else:
  while k+(k-1)*i< n:
    i+=1
print(1+i)

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

Solution (Python):
import math
def main():
    line_input = input().split()
    n = int(line_input[0])
    k = int(line_input[1])
    nums = input().split()
    print(math.ceil((n - 1) / (k - 1)))

main()

Solution (Python):
def c_minimization(N, K, A):
    return ((N - 1) + (K - 1) - 1) // (K - 1)  

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

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

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

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

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

minv = min(A)
minis = []
for i, a in enumerate(A):
    if a == minv:
        minis.append(i)

ans = 1e100
for mini in minis:
    l = mini // K + 1
    rd = K * l - l
    r = (N - 1 - rd - 1) // (K - 1) + 1
    ans = min(ans, l + r)
print(ans)

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

for ans in range(N):
    if N <= K:
        print(ans+1)
        break
    K += step

Solution (Python):
import math
N,K = map(int,input().split(" "))
array = list(map(int,input().split(" ")))
m = array.index(1)
i = m%(K-1) 
left = int((m-i)/(K-1))
right = math.ceil((N-m-(K-i))/(K-1))
print(left+right+1)

Solution (Python):
import sys
fin = sys.stdin.readline
from math import ceil

N, K = [int(elem) for elem in fin().split()]
A_list = [int(elem) for elem in fin().split()]

pos_1 = A_list.index(1)



min_operations = float('inf')
for offset in range(K):
    left_edge = pos_1 - offset
    right_edge = pos_1 + K - 1 - offset
    if left_edge >= 0 and right_edge >= 0:
        min_operations = min(min_operations, \
            ceil(left_edge / (K - 1)) + ceil((N - right_edge - 1) / (K - 1)) + 1)

print(min_operations)

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

if n == k:
    print(1)
    exit()

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

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

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

print(int(ans))

Solution (Python):
import math


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

    pos = A.index(1)
    l = math.ceil(pos / (K - 1))
    r = math.ceil((N - 1 - l * (K - 1)) / (K - 1))
    print(int(l + r))


if __name__ == "__main__":
    main()

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

minNum = min(A)

removedLen = len( [a for a in A if a != minNum ] )

import math

ans = math.ceil( removedLen/(K-1)) 

print(ans)

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

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

Solution (Python):
N, K = [int(_) for _ in input().split()]
input()
print(1 + (N - 2) // (K - 1))

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

for i in range(n):
    if a[i] == 1:
        min_idx = i
        break
ans = 10**9
for i in range(k):
    ans_cur = 1
    l = min_idx - i
    r = l + (k-1)
    if l > 0:
        ans_cur += l//(k-1)+1 if l%(k-1) > 0 else l//(k-1)
    if r < n-1:
        ans_cur += (n-1-r)//(k-1)+1 if (n-1-r)%(k-1) > 0 else (n-1-r)//(k-1)
    ans = min(ans, ans_cur)
print(ans)

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

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

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

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
a = list(li())

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

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

count = 0
n -= 1
while n > 0:
    n -= k-1
    count += 1

print(count)

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):
N,K = map(int,input().split())
A = list(map(int,input().split()))
cover = K
ans = 1
while cover < N:
    cover += (K-1)
    ans += 1
print(ans)

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

if n==k:print(ans)

else:
  while check < n:
    check += k - 1
    ans += 1
  print(ans)

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 numpy as np
n, k = map(int, input().split())
a = list(map(int, input().split()))


res = int(np.ceil((n-1)/(k-1)))

print(res)

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