CodeEff/ECCO huggingface dataset:
# Original solution
import sys

input = sys.stdin.readline


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

    q, r, = divmod(N - 1, K - 1)
    ans = q + int(r > 0)

    print(ans)


if __name__ == "__main__":
    main()


# Optimized solution
import sys

input = sys.stdin.readline


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

    q, r, = divmod(N - 1, K - 1)
    ans = q + int(r > 0)

    print(ans)


if __name__ == "__main__":
    main()
# Original solution
# -*- coding: utf-8 -*-
n, k = list(map(int,input().split()))
a = [int(i) for i in input().split()]

ans = ((n - 1) + (k - 1) - 1) // (k - 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
#!/usr/bin/env python3
import math

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

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


# Optimized solution
#!/usr/bin/env python3
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
N, M = list(map(int, input().split()))
LRD = [list(map(int, input().split())) for i in range(M)]


class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 重さの検索
    def weighting(self, x):
        self.find(x)
        return self.weight[x]

    # 併合
    def union(self, x, y, w):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.rank[px] < self.rank[py]:
                self.par[px] = py
                self.weight[px] = w - self.weight[x] + self.weight[y]
            else:
                self.par[py] = px
                self.weight[py] = -w - self.weight[y] + self.weight[x]
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 各頂点間の絶対距離
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

wuf = WeightedUnionFind(N)
for l, r, d in LRD:
    if wuf.same(l, r):
        if wuf.diff(l, r) != d:
            print("No")
            break
    else:
        wuf.union(l, r, d)
else:
    print("Yes")

# Optimized solution
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 重さの検索
    def weighting(self, x):
        self.find(x)
        return self.weight[x]

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


N, M = list(map(int, input().split()))
wuf = WeightedUnionFind(N)
for i in range(M):
    l, r, d = list(map(int, input().split()))
    if wuf.same(l, r):
        if wuf.diff(l, r) != d:
            print("No")
            break
    else:
        wuf.union(l, r, d)
else:
    print("Yes")
# Original solution
import sys
sys.setrecursionlimit(10 ** 6)
N, M = list(map(int, sys.stdin.readline().split()))
G = [[] for i in range(N)]
for i in range(M):
    l, r, d = list(map(int, sys.stdin.readline().split()))
    l, r = l - 1, r - 1
    G[l].append((r, d))
    G[r].append((l, -d))

R = [None] * N


def dfs(u):
    global R, G
    for w, d in G[u]:
        if R[w] is None:
            R[w] = R[u] + d
            if not dfs(w):
                return False
        else:
            if R[w] != R[u] + d:
                return False
    return True


flag = True
for i in range(N):
    if R[i] is None:
        R[i] = 0
        flag &= dfs(i)

if flag:
    print("Yes")
else:
    print("No")

# Optimized solution
import sys
sys.setrecursionlimit(10 ** 6)
N, M = list(map(int, sys.stdin.readline().split()))
G = [[] for i in range(N)]
for i in range(M):
    l, r, q = list(map(int, sys.stdin.readline().split()))
    G[l - 1].append((r - 1, q))
    G[r - 1].append((l - 1, -q))

R = [None] * N


def dfs(u):
    global R, G
    for w, d in G[u]:
        if R[w] is None:
            R[w] = R[u] + d
            if not dfs(w):
                return False
        else:
            if R[w] != R[u] + d:
                return False
    return True


flag = True
for i in range(N):
    if R[i] is None:
        R[i] = 0
        flag &= dfs(i)

if flag:
    print("Yes")
else:
    print("No")
# Original solution
import sys
from collections import deque

n, m = list(map(int, input().split()))
ed = [[] for _ in range(n)]
v = [None] * n
for _ in range(m):
	l, r, d = list(map(int, input().split()))
	ed[l-1].append([r-1, d])
	ed[r-1].append([l-1, -d])

def bfs(start):
	global ed, v
	visited = [False] * n
	s = deque([start])
	v[start] = 0
	while s:
		label = s.pop()
		if visited[label] == False:
			visited[label] = True
			for e in ed[label]:
				if v[e[0]] is None:
					v[e[0]] = v[label] + e[1]
					s.appendleft(e[0])
				else:
					if v[e[0]] != v[label] + e[1]:
						print("No")
						sys.exit()
	return

for i in range(n):
	if v[i] is None:
		bfs(i)

print("Yes")

# Optimized solution
import sys

n, m = list(map(int, input().split()))
ed = [[] for _ in range(n)]
v = [None] * n
for _ in range(m):
	l, r, d = list(map(int, input().split()))
	ed[l-1].append([r-1, d])
	ed[r-1].append([l-1, -d])

visited = [False] * n

def dfs(start):
	global ed, v, visited
	s = [start]
	v[start] = 0
	while s:
		label = s.pop()
		if visited[label] == False:
			visited[label] = True
			for e in ed[label]:
				if v[e[0]] is None:
					v[e[0]] = v[label] + e[1]
					s.append(e[0])
				else:
					if v[e[0]] != v[label] + e[1]:
						print("No")
						sys.exit()
	return

for i in range(n):
	if v[i] is None:
		dfs(i)

print("Yes")
# Original solution
import sys
from collections import deque

n,m = list(map(int, input().split()))
adj_list = [[] for i in range(n)]
for i in range(m):
    l, r, d = list(map(int, input().split()))
    adj_list[l-1].append((r-1, d))
    adj_list[r-1].append((l-1, -d))
def search(start, dist_all):
    q = deque([[start]])
    dist_all[i] = 0
    while(len(q) > 0):
        path = q.popleft()
        w = path[len(path) - 1]
        for x in adj_list[w]:
            if dist_all[x[0]] is None:
                dist_all[x[0]] = dist_all[w] + x[1]
                new_path = path[:]
                new_path.append(x[0])
                q.append(new_path)
            elif dist_all[x[0]] != dist_all[w] + x[1]:
                return False
    return True
dist_all = [None for i in range(n)]
for i in range(n):
    if dist_all[i] is None:
        if not search(i, dist_all):
            print('No')
            exit(0)
print('Yes')

# Optimized solution
import sys
from collections import deque

n,m = list(map(int, input().split()))
adj_list = [[] for i in range(n)]
for i in range(m):
    l, r, d = list(map(int, input().split()))
    adj_list[l-1].append((r-1, d))
    adj_list[r-1].append((l-1, -d))
def search(start, dist_all):
    q = deque([start])
    dist_all[i] = 0
    while(len(q) > 0):
        w = q.popleft()
        for x in adj_list[w]:
            if dist_all[x[0]] is None:
                dist_all[x[0]] = dist_all[w] + x[1]
                q.append(x[0])
            elif dist_all[x[0]] != dist_all[w] + x[1]:
                return False
    return True
dist_all = [None for i in range(n)]
for i in range(n):
    if dist_all[i] is None:
        if not search(i, dist_all):
            print('No')
            exit(0)
print('Yes')
# Original solution
import sys

sys.setrecursionlimit(100000)


def check(i, xs, checked):
    xi = xs[i]
    children = set()
    for j, d in links[i]:
        if j in checked:
            continue
        xj = xs[j]
        if xj is None:
            xs[j] = xi + d
        elif xi + d != xj:
            return False
        children.add(j)
    checked.add(i)
    for j in children:
        if j in checked:
            continue
        if not check(j, xs, checked):
            return False
    return True


def solve():
    checked = set()
    for i in range(n):
        if i not in checked:
            xs = [None] * n
            xs[i] = 0
            res = check(i, xs, checked)
            if not res:
                return False
            xf = [x for x in xs if x is not None]
            mn, mx = min(xf), max(xf)
            if mx - mn > 1e9:
                return False
    return True


n, m = list(map(int, input().split()))
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = list(map(int, input().split()))
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print(('Yes' if solve() else 'No'))


# Optimized solution
import sys

sys.setrecursionlimit(100000)


def check(i, xs, checked):
    xi = xs[i]
    children = set()
    for j, d in links[i]:
        if checked[j]:
            continue
        if j not in xs:
            xs[j] = xi + d
        elif xi + d != xs[j]:
            return False
        children.add(j)
    checked[i] = True
    for j in children:
        if not check(j, xs, checked):
            return False
    return True


def solve():
    checked = [False] * n
    for i in range(n):
        if not checked[i]:
            xs = {}
            xs[i] = 0
            res = check(i, xs, checked)
            if not res:
                return False
            mn, mx = min(xs.values()), max(xs.values())
            if mx - mn > 1e9:
                return False
    return True


n, m = list(map(int, input().split()))
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = list(map(int, input().split()))
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print(('Yes' if solve() else 'No'))
# Original solution
import sys

sys.setrecursionlimit(100000)


def check(i, xs, checked):
    xi = xs[i]
    children = set()
    for j, d in links[i]:
        if j in checked:
            continue
        if j not in xs:
            xs[j] = xi + d
        elif xi + d != xs[j]:
            return False
        children.add(j)
    checked.add(i)
    for j in children:
        if not check(j, xs, checked):
            return False
    return True


def solve():
    checked = set()
    for i in range(n):
        if i not in checked:
            xs = {}
            xs[i] = 0
            if not check(i, xs, checked):
                return False
    return True


n, m = list(map(int, input().split()))
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = list(map(int, input().split()))
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print(('Yes' if solve() else 'No'))


# Optimized solution
import sys

sys.setrecursionlimit(100000)


def check(i, xs, checked):
    xi = xs[i]
    children = set()
    for j, d in links[i]:
        if checked[j]:
            continue
        if j not in xs:
            xs[j] = xi + d
        elif xi + d != xs[j]:
            return False
        children.add(j)
    checked[i] = True
    for j in children:
        if not check(j, xs, checked):
            return False
    return True


def solve():
    checked = [False] * n
    for i in range(n):
        if not checked[i]:
            xs = {}
            xs[i] = 0
            if not check(i, xs, checked):
                return False
    return True


n, m = list(map(int, input().split()))
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = list(map(int, input().split()))
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print(('Yes' if solve() else 'No'))
# Original solution
import sys

sys.setrecursionlimit(100000)


def check(i, xs, checked):
    xi = xs[i]
    children = set()
    for j, d in links[i]:
        if checked[j]:
            continue
        if j not in xs:
            xs[j] = xi + d
        elif xi + d != xs[j]:
            return False
        children.add(j)
    checked[i] = True
    for j in children:
        if not check(j, xs, checked):
            return False
    return True


def solve():
    checked = [False] * n
    for i in range(n):
        if not checked[i]:
            xs = {}
            xs[i] = 0
            if not check(i, xs, checked):
                return False
    return True


n, m = list(map(int, input().split()))
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = list(map(int, input().split()))
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print(('Yes' if solve() else 'No'))


# Optimized solution
def check(si, xs, checked):
    q = [si]
    while q:
        i = q.pop()
        xi = xs[i]
        for j, d in links[i]:
            if checked[j]:
                continue
            if j not in xs:
                xs[j] = xi + d
            elif xi + d != xs[j]:
                return False
            q.append(j)
        checked[i] = True
    return True


def solve():
    checked = [False] * n
    for i in range(n):
        if not checked[i]:
            xs = {}
            xs[i] = 0
            if not check(i, xs, checked):
                return False
    return True


n, m = list(map(int, input().split()))
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = list(map(int, input().split()))
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print(('Yes' if solve() else 'No'))
# Original solution
def check(si, xs, checked):
    q = [si]
    while q:
        i = q.pop()
        xi = xs[i]
        for j, d in links[i]:
            if checked[j]:
                continue
            if j not in xs:
                xs[j] = xi + d
            elif xi + d != xs[j]:
                return False
            q.append(j)
        checked[i] = True
    return True


def solve():
    checked = [False] * n
    for i in range(n):
        if not checked[i]:
            xs = {}
            xs[i] = 0
            if not check(i, xs, checked):
                return False
    return True


n, m = list(map(int, input().split()))
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = list(map(int, input().split()))
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print(('Yes' if solve() else 'No'))


# Optimized solution
def check(si, xs, checked):
    q = {si}
    while q:
        i = q.pop()
        xi = xs[i]
        for j, d in links[i]:
            if checked[j]:
                continue
            if j not in xs:
                xs[j] = xi + d
            elif xi + d != xs[j]:
                return False
            q.add(j)
        checked[i] = True
    return True


def solve():
    checked = [False] * n
    for i in range(n):
        if not checked[i]:
            xs = {}
            xs[i] = 0
            if not check(i, xs, checked):
                return False
    return True


n, m = list(map(int, input().split()))
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = list(map(int, input().split()))
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print(('Yes' if solve() else 'No'))
# Original solution
def inpl(): return [int(i) for i in input().split()]
def find(x):
    if par[x] == x:
        return x
    else:
        par[x],dist[x] = find(par[x]),dist[x]+dist[par[x]]
        return par[x]
N, M = inpl()
par = list(range(N+1))
dist = [0 for _ in range(N+1)]

for _ in range(M):
    l, r, d = inpl()
    fl = find(l)
    fr = find(r)
    if fl == fr and d + dist[l] - dist[r] != 0:
        print('No')
        break
    else: 
        par[fr] = fl
        dist[fr] = d + dist[l] - dist[r]
else:
    print('Yes')


# Optimized solution
def inpl(): return [int(i) for i in input().split()]
def find(x):
    if par[x] == x:
        return x
    else:
        par[x],dist[x] = find(par[x]),dist[x]+dist[par[x]]
        return par[x]
N, M = inpl()
par = list(range(N+1))
dist = [0 for _ in range(N+1)]

for _ in range(M):
    l, r, d = inpl()
    fl = find(l)
    fr = find(r)
    if fl != fr:
        par[fr] = fl
        dist[fr] = d + dist[l] - dist[r]
    elif d + dist[l] - dist[r] != 0:
        print('No')
        break
else:
    print('Yes')
# Original solution
def inpl(): return [int(i) for i in input().split()]
def find(x):
    if par[x] == x:
        return x
    else:
        par[x],dist[x] = find(par[x]),dist[x]+dist[par[x]]
        return par[x]
N, M = inpl()
par = list(range(N+1))
dist = [0 for _ in range(N+1)]

for _ in range(M):
    l, r, d = inpl()
    fl = find(l)
    fr = find(r)
    if fl != fr:
        par[fr] = fl
        dist[fr] = d + dist[l] - dist[r]
    elif d + dist[l] - dist[r] != 0:
        print('No')
        break
else:
    print('Yes')


# Optimized solution
import sys
readline = sys.stdin.readline
class UFP():
    def __init__(self, num):
        self.par = [-1]*num
        self.dist = [0]*num
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            res = 0
            xo = x
            while self.par[x] >= 0:
                res += self.dist[x]
                x = self.par[x]
            self.dist[xo] = res
            self.par[xo] = x
            return x
    
    def union(self, x, y, d):
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            if self.par[rx] > self.par[ry]:
                rx, ry = ry, rx
                x, y = y, x
                d = -d
            self.par[rx] += self.par[ry]
            self.par[ry] = rx
            self.dist[ry] = d + self.dist[x] - self.dist[y]
            return True
        else:
            if d + self.dist[x] - self.dist[y]:
                return False
            return True

N, M = list(map(int, readline().split()))
T = UFP(N)
ans = 'No'
for _ in range(M):
    l, r, d = list(map(int, readline().split()))
    l -= 1
    r -= 1
    if not T.union(l, r, d):
        break
else:
    ans = 'Yes'
print(ans)
# Original solution
N,M = list(map(int,input().split()))
edge = [[None]*(N+1) for _ in range(N+1)]
for _ in range(M):
    l,r,d = list(map(int,input().split()))
    edge[l][r] = d
    edge[r][l] = -d
G = [None]*(N+1)
ok = True
stack = []
for x in range(1,N+1):
    if G[x] is not None: continue
    G[x] = 0
    stack = [x]
    while stack:
        v = stack.pop()
        for to in range(1,N+1):
            if edge[v][to] is None:
                continue
            d = edge[v][to]
            if G[to] is None:
                G[to] = G[v] + d
                stack.append(to)
            else:
                if G[to] != G[v] + d:
                    ok = False
                    break
    if ok == False:
        break
print(('Yes' if ok else 'No'))

# Optimized solution
N,M = list(map(int,input().split()))
edge =[[] for _ in range(N+1)]
for _ in range(M):
    l,r,d = list(map(int,input().split()))
    edge[l].append([r,d])
    edge[r].append([l,-d])
G = [None]*(N+1)
ok = True
stack = []
for x in range(1,N+1):
    if G[x] is not None: continue
    G[x] = 0
    stack = [x]
    while stack:
        v = stack.pop()
        for to,d in edge[v]:
            if G[to] is None:
                G[to] = G[v] + d
                stack.append(to)
            else:
                if G[to] != G[v] + d:
                    ok = False
                    break
    if ok == False:
        break
print(('Yes' if ok else 'No'))
# Original solution
import sys
import copy
sys.setrecursionlimit(10**6)
N,M=list(map(int,input().split()))

D=[]
P=[[i,0]for i in range(N+1)]
C=[1 for i in range(N+1)]
A=[0]

for i in range(M):
    l,r,d=list(map(int,input().split()))
    P[r]=[l,d]
    D.append([l,r,d])
#print(P)
def find(a,b):
    if c[a]==0:
        return a,b
    elif a==P[a][0]:
        return a,b
    else:
        c[a]=0
        return find(P[a][0],b+P[a][1])
for i in range(1,N+1):
    c=copy.deepcopy(C)
    A.append(find(i,0))
#print(A)
for i in range(M):
    if A[D[i][1]][1]-A[D[i][0]][1]!=D[i][2]:
        print("No")
        exit()
print("Yes")


# Optimized solution
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)

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

L=[[]for i in range(N+1)]
D=dict()
for i in range(M):
    l,r,d=list(map(int,input().split()))
    L[l].append([r,d])
    L[r].append([l,-d])
    D[i]=(l,r,d)
    
C=["N" for i in range(N+1)]

def dfs(x):
    for i,j in L[x]:
        if C[i]=="N":
            C[i]=C[x]+j
            dfs(i)

for i in range(1,N+1):
    if C[i]=="N":
        C[i]=0
        dfs(i)
#print(C)
#print(D)
for i in range(M):
    l,r,d=D[i]
    if C[r]-C[l]!=d:
        print("No")
        exit()
print("Yes")
# 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**15
mod = 10**9+7

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)


def main():
    n,m = LI()
    a = [LI() for _ in range(m)]
    e = collections.defaultdict(list)
    r = [0] * n
    f = [False] * n
    for l,r,d in a:
        e[l-1].append((r-1,d))
        e[r-1].append((l-1,-d))
        f[r-1] = False

    b = ['s'] * n
    def g(i,c):
        if f[i] and c != 's':
            return False
        if b[i] != 's':
            if c == 's':
                return True
            return b[i] == c
        if c == 's':
            c = 0
        b[i] = c
        for r,d in e[i]:
            if not g(r,c+d):
                return False
        return True

    for i in range(n):
        if not g(i,'s'):
            return 'No'
    return 'Yes'


print(main())





# 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**15
mod = 10**9+7

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)


def main():
    n,m = LI()
    a = [LI() for _ in range(m)]
    e = collections.defaultdict(list)
    for l,r,d in a:
        e[l-1].append((r-1,d))
        e[r-1].append((l-1,-d))

    b = [False] * n
    def g(i,c):
        if b[i] != False:
            if c == False:
                return True
            return b[i] == c
        if c == False:
            c = 0
        b[i] = c
        for r,d in e[i]:
            if not g(r,c+d):
                return False
        return True

    for i in range(n):
        if not g(i,False):
            return 'No'
    return 'Yes'


print(main())