CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))
cmin = 10**5
for x in range(1,N):
    y = str(N-x)
    x = str(x)
    cnt = 0
    for i in range(len(x)):
        cnt += int(x[i])
    for j in range(len(y)):
        cnt += int(y[j])
    cmin = min(cmin,cnt)
print(cmin)

# Optimized solution
N = int(eval(input()))
cmin = 1000
for i in range(1,N):
    a = str(i)
    cnt = 0
    for j in range(len(a)):
        cnt += int(a[j])
    b = str(N-i)
    for j in range(len(b)):
        cnt += int(b[j])
    cmin = min(cmin,cnt)
print(cmin)
# Original solution
N = int(eval(input()))
cmin = 1000
for i in range(1,N):
    a = str(i)
    cnt = 0
    for j in range(len(a)):
        cnt += int(a[j])
    b = str(N-i)
    for j in range(len(b)):
        cnt += int(b[j])
    cmin = min(cmin,cnt)
print(cmin)

# Optimized solution
N = int(eval(input()))
cmin = N
for i in range(1,N//2):
    j = N-i
    a = str(i)
    b = str(j)
    cnt = 0
    for k in range(len(a)):
        cnt += int(a[k])
    for k in range(len(b)):
        cnt += int(b[k])
    cmin = min(cmin,cnt)
print(cmin)
# Original solution
n = int(eval(input()))
m = n
sum = 0


for i in range(n):
    sum = m % 10 + sum
    m = m//10

if sum == 1:
    print((10))
else:
    print(sum)

# Optimized solution
n = int(eval(input()))
sum = 0

for i in str(n):
    sum += int(i)
if sum == 1:
    sum += 9
print(sum)
# Original solution
def digitsum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

N = int(eval(input()))
summin = 10**5
for i in range(1,int(N/2)+1) : 
	A = i
	B = N - i

	sumab = digitsum(A) + digitsum(B)
	if (summin > sumab) :
		summin = sumab

print(summin)

# Optimized solution
N = int(eval(input()))
ans = float('inf')
for i in range(N//2):
  A = i+1
  B = N-A
  ans = min(ans, sum(list(map(int,str(A)))) + sum(list(map(int,str(B))) ))

print(ans)
# Original solution
ans=999999999
n = int(eval(input()))
for i in range(1,n//2+1):
    x=str(i)
    y=str(n-i)
    ans=min(ans, sum(map(int, x))+sum(map(int, y)))
    
print(ans)

# Optimized solution
n=int(eval(input()))
if n%10==0:
    print((10))
else:
    print((sum(map(int,list(str(n))))))
# Original solution
N = int(eval(input()))

summ = []
for i in range(1,N//2 + 1):
    A = []
    B = []
    k = N-i
    for __ in range(6):
        A.append(int(i%10))
        B.append(int(k%10))
        i /= 10
        k /= 10
    summ.append(sum(A+B))
print((min(summ)))

# Optimized solution
N = int(eval(input()))

if N%10 == 0:
    print((10))
else:
    l = []
    for i in range(6):
        l.append(int(N%10))
        N /= 10
    print((sum(l)))
# Original solution
n = int(eval(input()))
mt = 10 ** 9
for i in range(1, n):
    t = 0
    for j in range(len(str(i))):
        t += int(str(i)[j])
    for j in range(len(str(n - i))):
        t += int(str(n - i)[j])
    mt = min(mt, t)
print(mt)


# Optimized solution
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    m_t = 10 ** 10
    for i in range(1, n):
        a = list(map(int, list(str(i))))
        b = list(map(int, list(str(n-i))))
        m_t = min(m_t, sum(a) + sum(b))
    print(m_t)


if __name__ == '__main__':
    slove()
# Original solution
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    m_t = 10 ** 10
    for i in range(1, n):
        a = list(map(int, list(str(i))))
        b = list(map(int, list(str(n-i))))
        m_t = min(m_t, sum(a) + sum(b))
    print(m_t)


if __name__ == '__main__':
    slove()


# Optimized solution
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    mt = 10 ** 20
    for i in range(1, n // 2 + 1):
        sa = str(i)
        sb = str(n - i)
        t = 0
        for j in range(len(sa)):
            t += int(sa[j])
        for j in range(len(sb)):
            t += int(sb[j])
        mt = min(mt, t)
    print(mt)


if __name__ == '__main__':
    slove()
# Original solution
N = int(eval(input()))
ans = 9999999
for a in range(1,N):
    b = N-a
    tmp = 0
    for ac in str(a):
        tmp += int(ac)
    for bc in str(b):
        tmp += int(bc)
    ans = min(ans, tmp)
print(ans)


# Optimized solution
N = int(eval(input()))

ans = 9999
for a in range(1,N):
    b = N-a
    x = sum(map(int,str(a)))
    y = sum(map(int,str(b)))
    ans = min(ans, x+y)
print(ans)
# Original solution
N = int(eval(input()))
a = 0

for i in str(N):
    a += int(i)
if a == 1:
    print((10))
else:
    print(a)

# Optimized solution
N = int(eval(input()))

if N % 10 == 0:
    print((10))
else:
    print((sum(list(map(int, str(N))))))
# Original solution
# AGC 025 A - Digits Sum
N = int(eval(input()))

def sum_of(num): 
    list_b = []
    k = 0
    while num > 0:
        list_b.append(num%10)
        num //= 10
    for i in range(len(list_b)):
        k += list_b[i]
    return k 

list_a =[]
if N <= 10:
    print((str(N)))
if N > 10:
    for i in range(2,N-1):
        A = i
        B = N - i
        list_a.append(sum_of(A) + sum_of(B))
    print((min(list_a)))

# Optimized solution
# AGC 025 A - Digits Sum
N = int(eval(input()))

def sum_of(num): 
    list_b = []
    k = 0
    while num > 0:
        list_b.append(num%10)
        num //= 10
    for i in range(len(list_b)):
        k += list_b[i]
    return k 

list_a =[]
if N <= 10:
    print((str(N)))
if N > 10:
    for i in range(2,(N-1)//2+1):
        A = i
        B = N - i
        list_a.append(sum_of(A) + sum_of(B))
    print((min(list_a)))
# Original solution
n = int(eval(input()))
ans = float('Inf')
for i in range(1, n):
  if i > n//2:
    break
  if eval('+'.join(str(i))) + eval('+'.join(str(n - i))) < ans:
    ans = eval('+'.join(str(i))) + eval('+'.join(str(n - i)))
print(ans)

# Optimized solution
n = int(eval(input()))
ans = float('Inf')
for i in range(1, n//2+1):
  if sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i)))) < ans:
    ans = sum(list(map(int, str(i)))) + sum(list(map(int, str(n - i))))
print(ans)
# Original solution
n = int(eval(input()))
ans = 100000
for i in range(1, n):
    a, b = str(i), str(n-i)
    A, B = 0, 0
    for x in a:
        A += int(x)
    for y in b:
        B += int(y)
    ans = min(ans, A+B)
print(ans)

# Optimized solution
n = int(eval(input()))
for i in range(1,6):
    if n%(10*i) == 0:
        print((10))
        exit()
print((sum(list(map(int, str(n))))))
# Original solution
n = int(eval(input()))
_list = []

for a in range(1, n):

    b = n - a
    _list.append(sum(list(map(int, str(a)[::]))) + sum(list(map(int, str(b)[::]))))

print((min(_list)))

# Optimized solution
N = int(eval(input()))
n = 10 ** (len(str(N-1)) - 1)
a = list(str(N - n))
print((sum(list(map(int, a)))+1))
# Original solution
def digits_sum(n):
    return sum(int(c) for c in str(n))


N = int(eval(input()))
ans = float("inf")
for i in range(1, N):
    A = i
    B = N - i
    ans = min(ans, digits_sum(A) + digits_sum(B))
print(ans)


# Optimized solution
def digit_sum(x):
    res = 0
    while x > 0:
        res += x % 10
        x //= 10
    return res


N = int(eval(input()))
ans = N
for i in range(1, N):
    A = i
    B = N - i
    ans = min(ans, digit_sum(A) + digit_sum(B))
print(ans)
# Original solution
def wa(t):
    sum=0
    while t>0:
       sum+=t%10
       t//=10
    return sum

n=int(eval(input()))
ans=[]
for i in range(1,n):
    ans.append(wa(i)+wa(n-i)) 
    if wa(i)+wa(n-i)==1:
        print(i)
print((min(ans)))

# Optimized solution
def wa(t):
    sum=0
    while t>0:
       sum+=t%10
       t//=10
    return sum

n=int(eval(input()))
ans=[]
for i in range(1,n):
    ans.append(wa(i)+wa(n-i)) 
print((min(ans)))
# Original solution
import sys

def digits_sum(x):
    return sum(list(map(int, str(x))))

def solve(n):
    ans = sys.maxsize
    for a in range(1, n):
        b = n - a
        ans = min(ans, digits_sum(a) + digits_sum(b))

    return ans

if __name__ == '__main__':
    n = int(eval(input()))
    print((solve(n)))


# Optimized solution
import sys

def digits_sum(x):
    return sum(map(int, str(x)))

def solve(n):
    ans = sys.maxsize
    for a in range(1, n):
        b = n - a
        ans = min(ans, digits_sum(a) + digits_sum(b))

    return ans

if __name__ == '__main__':
    n = int(eval(input()))
    print((solve(n)))
# Original solution
N = int(eval(input()))
results = ''
for A in range(N + 1):
    if A == 0:
        continue

    BBB = []
    AAA = []

    B = N - A
    if B >= 1:
        for b in range(len(str(B))):
            BBB.append(int(str(B)[b]))

        for a in range(len(str(A))):
            AAA.append(int(str(A)[a]))
        sums = sum(BBB) + sum(AAA)
        if sums == 1:
            print(A)
            print(B)
            print(AAA)
            print(BBB)

        if not results:
            results = sums
        else:
            if results > sums:
                results = sums
print(results)

# Optimized solution
# 記録
N = int(eval(input()))
results = []
for i in range(1,N):
    results.append(sum(map(int,str(i))) + sum(map(int,str(N-i))))
print((min(results)))
# Original solution
def a_digits_sum(N):
    def digit_sum(n):  # 非負整数nの各桁の和
        str_n = str(n)
        ret = 0
        for c in str_n:
            ret += int(c)
        return ret

    ans = float('inf')
    for A in range(1, N):
        B = N - A
        ans = min(ans, digit_sum(A) + digit_sum(B))
    return ans

N = int(eval(input()))
print((a_digits_sum(N)))

# Optimized solution
def a_digits_sum(N):
    # A+B のk桁目を c_k、Nのk桁目をn_kとおくと、筆算の考え方より、
    # c_k=n_k となるようにすればいい。つまり解はNの各桁の和に等しい。
    # ただし、Nが10の冪乗のときは、上の考え方では片方がNに等しくなってしまう。
    # この場合、 N=10^k とすると、 A=a*10^(k-1), B=b*10^(k-1) (ただし a+b=10)
    # の形にするしかない。よってA+Bの各桁の和は常に10。
    ans = 0
    n = str(N)
    for c in n:
        ans += int(c)
    if ans == 1:
        # 最上位桁に1が出て、その後0しか出ていない。Nは10の冪乗だった
        ans = 10
    return ans

N = int(eval(input()))
print((a_digits_sum(N)))
# Original solution
#! /usr/bin/env python3

N = int(eval(input()))
ans = 10000000
for i in range(1, N):
    s = sum(map(int, str(i))) + sum(map(int, str(N - i)))
    ans = min(ans, s)
print(ans)

# Optimized solution
N=int(eval(input()));print((min(sum(map(int,str(i)+str(N-i)))for i in range(1,N))))
# Original solution
N = int(eval(input()))
ans = N
for i in range(1,N):
    A,B = 0,0
    A_str = list(str(i))
    B_str = list(str(N-i))
    for e in A_str:
        A += int(e)
    for e in B_str:
        B += int(e)
    if A + B < ans:
        ans = A + B       
print(ans)

# Optimized solution
def degit_sum(n):
    if len(str(n)) < 2:
        return n
    s = list(str(n))
    s = [int(e) for e in s]
    return sum(s)

N = int(eval(input()))
degit = len(str(N))
if N % pow(10,degit-1) == 0 and N >= 10:
    degit -= 1
A = pow(10,degit-1)
B = N - A
ans = degit_sum(A) + degit_sum(B)
print(ans)
# Original solution
#!/usr/bin/env python

n = int(eval(input()))

def sumdigits(n):
    ret = 0 
    s = list(str(n))
    for i in range(len(s)):
        ret += int(s[i])
    return ret 

a = 1 
ans = 1000000
while n-a > 0:
    tmp = sumdigits(a) + sumdigits(n-a)
    if ans >= tmp:
        ans = tmp 
    a += 1

print(ans)


# Optimized solution
#!/usr/bin/env python
import math

n = int(eval(input()))
m = math.log10(n)
if int(m) == m:
    print((10))
    exit()

ans = sum(map(int, list(str(n))))
print(ans)
# Original solution
# ARC082C - Together (ABC072C)
n = int(eval(input()))
lst = list(map(int, input().rstrip().split()))
ans = [0] * 100001
for i in lst:
    ans[i] += 1
print((max(list(map(sum, list(zip(ans, ans[1:], ans[2:])))))))

# Optimized solution
# ARC082C - Together (ABC072C)
def main():
    n = int(eval(input()))
    lst = list(map(int, input().rstrip().split()))
    ans = [0] * 100001
    for i in lst:
        ans[i] += 1
    print((max(list(map(sum, list(zip(ans, ans[1:], ans[2:])))))))


if __name__ == "__main__":
    main()
# Original solution
from collections import Counter
from operator import itemgetter

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

c = Counter(a)

def num(n):
	if n in list(c.keys()):
		return c[n]
	else:
		return 0

ans = 0

for i in range(99998):
	candidate = num(i) + num(i+1) + num(i+2)
	if candidate > ans:
		ans = candidate

print(ans)

# Optimized solution
from collections import Counter
from operator import itemgetter

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

c = Counter(a)

def num(n):
	if n in list(c.keys()):
		return c[n]
	else:
		return 0

candidate = num(0) + num(1) + num(2)
ans = candidate

for i in range(1, 99998):
	candidate -= num(i-1)
	candidate += num(i+2)
	if candidate > ans:
		ans = candidate

print(ans)
# Original solution
n = int(eval(input()))
dic = {}

for i in map(int, input().split()):
    for j in range(i-1, i+1+1):
        if j not in dic:
            dic[j] = 0
        dic[j] += 1

print((max(dic.values())))

# Optimized solution
n = int(eval(input()))
dic = {}
for a in map(int, input().split()):
    for i in range(a-1, a+2):
        if i not in dic:
            dic[i] = 0
        dic[i] += 1
print((max(dic.values())))
# Original solution
from collections import Counter
N = int(eval(input()))

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

d = Counter(A)

ans = 0
for i in range(1, 10**5+1):
    tmp = d[i-1] + d[i] + d[i+1]
    ans = max(tmp, ans)
print(ans)


# Optimized solution
from collections import Counter
N = int(eval(input()))

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

d = Counter(A)

ans = 0
for k in list(d.keys()):
    tmp = d[k-1] + d[k] + d[k+1]
    ans = max(ans, tmp)
print(ans)
# Original solution
import collections

n = int(eval(input()))
a = list(map(int, input().split()))
ac = collections.Counter(a)
ans = 0
for i in range(min(a) - 1, max(a) + 2):
    total = 0
    for j in ac:
        if j == i or j + 1 == i or j - 1 == i:
            total += ac[j]
    ans = max(ans, total)
print(ans)

# Optimized solution
import collections

n = int(eval(input()))
a = list(map(int, input().split()))
ac = collections.Counter(a)
ans = 0
for i in range(min(a) - 1, max(a) + 2):
    ans = max(ans, ac[i - 1] + ac[i] + ac[i + 1])
print(ans)
# Original solution
import sys
import bisect


def main():
    n, *a = list(map(int, sys.stdin.read().split()))
    lr = [[i - 1,i + 1] for i in a]
    lr.sort(key=lambda x: x[0])
    l = [i[0] for i in lr]
    res = 0
    for i in range(n):
        right = bisect.bisect(l, lr[i][1])
        left = bisect.bisect_left(l, l[i])
        res = max(res, right - left)
    print(res)


if __name__ == '__main__':
    main()

# Optimized solution
import sys
from itertools import accumulate


def main():
    n, *A = list(map(int, sys.stdin.read().split()))
    minA = min(A) - 1
    lr = [[i - 1 - minA, i + 1 - minA] for i in A]
    lst = [0] * (max(A) - minA + 3)
    for i, j in lr:
        lst[i] += 1
        lst[j + 1] -= 1
    lst = list(accumulate(lst))
    print((max(lst)))


if __name__ == '__main__':
    main()
# Original solution

N = int(eval(input()))
A = [int(i) for i in input().split()]

B = []
for i in A:
    B.append(i - 1)
    B.append(i)
    B.append(i + 1)

Bset = set(B)
C = []
for i in Bset:
    C.append(len(list([x for x in B if x == i])))

print((max(C)))



# Optimized solution
N = int(eval(input()))
A = [int(i) for i in input().split()]

B = []
for i in A:
    B.append(i - 1)
    B.append(i)
    B.append(i + 1)
B.sort()

C = []
count = 0
for i in range(len(B)):
    if B[i] == B[i - 1]:
        count += 1
    else:
        C.append(count + 1)
        count = 0

print((max(C)))
# Original solution
import collections
N = int(eval(input()))
a = list(map(int, input().split()))
c = collections.Counter(a)
ans = 0
for i in c:
  t = c[i-1] + c[i] + c[i+1]
  if ans < t:
    ans = t
print(ans)

# Optimized solution
from collections import Counter
N = int(eval(input()))
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for i in c:
  t = c[i-1] + c[i] + c[i+1]
  if ans < t:
    ans = t
print(ans)
# Original solution
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))



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



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))
# Original solution
n,k,*_=list(map(int,open(0).read().split()))
print((0--~-n//~-k))

# Optimized solution
n,k=list(map(int,input().split()))
print((0--~-n//~-k))
# Original solution
N,K=(int(i) for i in input().split())
A = list(int(i) for i in input().split())  
minNum=0
i=0
A2=[]
ans=0

A2.extend(A[i:i+K])
while i<N:    
    #print(A2)
    minNum=int(min(A2))
   # print(minNum)
    j=i
    #特定範囲の最小化
    while j<i+K:
        #途中でオーバーしたら逃げる
        if len(A2)<=j:
            break
        #print(A2[j])
        A2[j]=minNum
        j+=1
    if i==0:
        i=i+K
    else:
        i=i+K-1

    ans+=1
    A2.extend(A[i:i+K-1])

#print(A2)
print(ans)    



# Optimized solution
N,K=(int(i) for i in input().split())
A = list(int(i) for i in input().split())  
minNum=0
i=0
A2=[]
ans=0

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

    ans+=1
    
print(ans)
# 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
import math

N, K = list(map(int, input().split()))
print((math.ceil((N - 1) / (K - 1))))
# Original solution
[N, K] = list(map(int, input().split()))
A = list(map(int, input().split()))
count = 0
while len(A) != 1:
  A = A[K:] + [0]
  count = count + 1 
print(count)


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

n, k = list(map(int, input().split()))
[int(i) for i in input().split()]
print((math.ceil((n-k) / (k - 1) + 1)))

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

N -= K
ans = 1

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

print(ans)


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

ans = 1
N -= K

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

print(ans)
# Original solution
N,K = list(map(int,input().split()))
A = [int(i) for i in input().split()]

ans = 0

minA = min(A)

for i in range(len(A)):
        if A[i] == minA:
                A[i] = 0
        else:
                A[i] = 1

while 1 in A:
        if len(A) <= K:
                ans += 1
                break
        if A[0] == 0:
                if A[1] == 0:
                        A = A[1:]
                elif 0 in A[1:1+K]:
                        A[K] = 0
                        A = A[K:]
                        ans += 1
                else:
                        A[K-1] = 0
                        A = A[K-1:]
                        ans += 1
        else:
                A = A[K-1:]
                ans += 1
print(ans)

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

print(((N-1)//(K-1)+((N-1)%(K-1)!=0)))
# Original solution
def main():
    n, k, *a = list(map(int, open(0).read().split()))
    ans = 1 + (n - k) // (k - 1) + ((n - k) % (k - 1) != 0)
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n, k = list(map(int, input().split()))
    ans = 1 + (n - k) // (k - 1) + ((n - k) % (k - 1) != 0)
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
#1にしなきゃいけない
from math import*

n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
#b=a.index(1)
#print(n,k,b)

#l=b
#r=n-b-1
print(((n-1+k-1-1)//(k-1)))


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


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

print((ceil((n-k)/(k-1)) + 1))
# Original solution
n,k=list(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()


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

# Optimized solution
import math

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

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

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


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

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

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

# Optimized solution
M, N =list(map(int, input().split()))
print((-(-(M-1)//(N-1))))