There is a toy building consisting of $n$ towers. Each tower consists of several cubes standing on each other. The $i$-th tower consists of $h_i$ cubes, so it has height $h_i$.

Let's define operation slice on some height $H$ as following: for each tower $i$, if its height is greater than $H$, then remove some top cubes to make tower's height equal to $H$. Cost of one "slice" equals to the total number of removed cubes from all towers.

Let's name slice as good one if its cost is lower or equal to $k$ ($k \ge n$).

 [Image] 

Calculate the minimum number of good slices you have to do to make all towers have the same height. Of course, it is always possible to make it so.


-----Input-----

The first line contains two integers $n$ and $k$ ($1 \le n \le 2 \cdot 10^5$, $n \le k \le 10^9$) — the number of towers and the restriction on slices, respectively.

The second line contains $n$ space separated integers $h_1, h_2, \dots, h_n$ ($1 \le h_i \le 2 \cdot 10^5$) — the initial heights of towers.


-----Output-----

Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.


-----Examples-----
Input
5 5
3 1 2 2 4

Output
2

Input
4 5
2 3 4 5

Output
2



-----Note-----

In the first example it's optimal to make $2$ slices. The first slice is on height $2$ (its cost is $3$), and the second one is on height $1$ (its cost is $4$).

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Greedy algorithms


Solutions:
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
g = A[-1]
h = A[0]
p = 0
i = 1
c = 0
l = 0
while h > g and i < n:
	if A[i] == A[p]:
		p += 1
		i += 1
		continue
	for j in range(A[p] - A[i]):
		c += p + 1
		l += 1
		if c > k:
			ans += 1
			h -= l - 1
			c = p + 1
			l = 0
			if h <= g:
				break
	p = i
	i += 1
if h > g:
	ans += 1
print(ans)


def main():
	(n, k) = map(int, input().split())
	cnt = [0] * 200001
	for i in map(int, input().split()):
		cnt[i] += 1
	cnt[0] = n
	r = m = c = 0
	for t in reversed(cnt):
		c += t
		if c == n:
			r += m != 0
			break
		if m + c > k:
			r += 1
			m = c
		else:
			m += c
	print(r)
main()


(n, k) = map(int, input().split())
heights = sorted(list(map(int, input().split())), reverse=True)
height = heights[0]
cost = 0
level = 0
for i in range(n):
	while heights[i] < height:
		height -= 1
		if cost + i > k:
			level += 1
			cost = i
		else:
			cost += i
if cost > 0:
	level += 1
print(level)


from bisect import bisect_right as br
from sys import stdin
(n, k) = map(int, stdin.readline().strip().split())
s = list(map(int, stdin.readline().strip().split()))
s.sort()
dp = [-1 for i in range(s[-1])]
for i in range(s[-1]):
	dp[i] = n - br(s, i)
ans = 0
acum = 0
while len(dp) > 0 and dp[-1] != n:
	if acum + dp[-1] > k:
		ans += 1
		acum = 0
	acum += dp[-1]
	dp.pop()
if acum != 0:
	ans += 1
print(ans)


import sys
input = sys.stdin.buffer.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(mi, ma) = (min(a), max(a))
l = [0] * (ma + 1)
l[0] = n
for i in a:
	l[i] -= 1
for i in range(1, ma + 1):
	l[i] += l[i - 1]
sum = 0
ans = 0
for i in range(ma + 1):
	if l[i] < n:
		sum += l[i]
		if sum > k:
			sum = l[i]
			ans += 1
ans += 1 if sum else 0
print(ans)


3
import math
import sys
DEBUG = False

def inp():
	return sys.stdin.readline().rstrip()

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)

def solve(N, K, H):
	H.sort(reverse=True)
	while len(H) >= 2 and H[-2] == H[-1]:
		H.pop()
	width = 0
	cnt = 0
	remain = 0
	for i in range(len(H) - 1):
		h = H[i]
		h1 = H[i + 1]
		width += 1
		height = h - h1
		dprint('i={} h={} h1={} width={} height={} cnt={} remain={}'.format(i, h, h1, width, height, cnt, remain))
		if height == 0:
			continue
		if remain + width * height < K:
			remain += width * height
			continue
		dh = (K - remain) // width
		dprint('dh={}'.format(dh))
		assert dh <= height
		remain = 0
		height -= dh
		cnt += 1
		if width * height < K:
			remain += width * height
			continue
		dprint('A: height={} cnt={}'.format(height, cnt))
		t = K // width
		assert t >= 1
		dprint('t={}'.format(t))
		sets = height // t - 1
		dprint('sets={}'.format(sets))
		height -= t * sets
		cnt += sets
		dprint('B: height={} cnt={}'.format(height, cnt))
		while width * height >= K:
			height -= t
			cnt += 1
			dprint('C: height={} cnt={}'.format(height, cnt))
		assert width * height < K
		remain += height * width
	assert remain < K
	if remain > 0:
		cnt += 1
	return cnt

def main():
	(N, K) = [int(e) for e in inp().split()]
	H = [int(e) for e in inp().split()]
	assert len(H) == N
	print(solve(N, K, H))

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
h = sorted(list(map(int, input().split())), reverse=True)
max_h = h[0]
prices = []
cur_h = max_h
for i in range(n):
	while h[i] < cur_h:
		cur_h -= 1
		prices.append(i)
r = 0
cur_price = 0
for i in range(len(prices)):
	if cur_price + prices[i] > k:
		r += 1
		cur_price = prices[i]
	else:
		cur_price += prices[i]
if cur_price != 0:
	r += 1
print(r)


from math import ceil
from collections import Counter

def f(n, k, a):
	cnt = Counter(a)
	need = min(a)
	mx = max(a)
	pos = 2 * 10 ** 5 + 9
	ans = 0
	s = 0
	c = 0
	while True:
		x = s - c * (pos - 1)
		if x > k:
			ans += 1
			h = pos
			s = pos * c
		pos -= 1
		if pos == need:
			break
		c += cnt[pos]
		s += cnt[pos] * pos
	if mx != need:
		ans += 1
	return ans
(n, k) = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
print(f(n, k, l))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
c = 0
p = a[-1]
q = a[0]
v = 1
m = 0
while q != p:
	while q == a[v]:
		v = v + 1
	if c + v > k:
		m = m + 1
		c = v
	else:
		c = c + v
	q = q - 1
if c > 0:
	m = m + 1
print(m)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
import heapq
from collections import Counter
from bisect import bisect_right
import bisect
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
d = Counter(arr)
ma = max(arr)
mi = min(arr)
var = 0
ans = 0
for i in range(ma - 1, mi - 1, -1):
	if var + d[i + 1] <= k:
		var += d[i + 1]
	else:
		ans += 1
		var = d[i + 1]
	d[i] = d.get(i, 0) + d[i + 1]
if var > 0:
	print(ans + 1)
else:
	print(ans)


(n, k) = map(int, input().split())
temp = [int(x) for x in input().split()]
m1 = max(temp)
m2 = min(temp)
delta = m1 - m2
line = [0] * delta
for i in temp:
	v = m1 - i
	if v < delta:
		line[v] += 1
for i in range(1, len(line)):
	line[i] = line[i - 1] + line[i]
cnt = 0
s = 0
for i in range(len(line)):
	s += line[i]
	if s > k:
		cnt += 1
		s = line[i]
if s > 0:
	cnt += 1
print(cnt)


from collections import defaultdict

def ii():
	return list(map(int, input().split()))
maxv = int(200000.0) + 1
(n, k) = ii()
cnt = defaultdict(int)
for a in ii():
	cnt[a] += 1
for i in range(maxv, -1, -1):
	cnt[i] += cnt[i + 1]
(cur, ans) = (0, 0)
i = maxv
while True:
	if cnt[i] == n:
		if cur:
			ans += 1
		break
	if cur + cnt[i] > k:
		ans += 1
		cur = 0
	cur += cnt[i]
	i -= 1
print(ans)


from sys import stdin
from collections import *

def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return list(stdin.readline()[:-1])
(n, k) = arr_inp(1)
a = sorted(arr_inp(1))
(mem, ans, cum, h, tem) = (Counter(a), 0, 0, [0] * (a[-1] + 1), 0)
for i in range(a[-1], 0, -1):
	h[i] += cum + mem[i]
	cum += mem[i]
for i in range(len(h) - 1, a[0], -1):
	tem += h[i]
	if i > 0 and h[i - 1] + tem > k:
		ans += 1
		tem = 0
print(ans + 1 if tem else ans)


(n, k) = list(map(int, input().split()))
hieght_li = list(map(int, input().split()))
low = min(hieght_li)
high = max(hieght_li)
cost = 0
cnt = 0
a = 0
dh = high - low
li = [0] * dh + [0]
for cur in hieght_li:
	li[high - cur] += 1
if len(li) == 1:
	print(0)
else:
	for i in range(high - 1, low - 1, -1):
		b = cost + a + li[-i + high - 1]
		if b > k:
			cnt += 1
			a = a + li[-i + high - 1]
			cost = a
			continue
		a = a + li[-i + high - 1]
		cost = cost + a
	print(cnt + 1)


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
t = sorted(t, reverse=True)
tt = []
f_max = t[0]
f_min = t[-1]
if f_max == f_min:
	print(0)
	exit(0)
h = []
tmp_sum = 1
count = 0
wyn = 0
for x in range(0, len(t) - 1, +1):
	if t[x] == t[x + 1]:
		tmp_sum += 1
	else:
		tt.append([t[x], tmp_sum])
		tmp_sum = 1
tt.append([t[-1], tmp_sum])
c = 0
for x in range(0, len(tt) - 1, +1):
	a = tt[x][0]
	b = tt[x][1]
	a1 = tt[x + 1][0]
	a2 = tt[x + 1][1]
	c += b
	for y in range(0, a - a1, +1):
		h.append(c)
xx = 0
floor_sum = 0
while True:
	if floor_sum + h[xx] > m:
		wyn += 1
		floor_sum = 0
		continue
	if floor_sum == m:
		wyn += 1
		floor_sum = 0
	floor_sum += h[xx]
	xx += 1
	if xx == len(h):
		if floor_sum > 0:
			wyn += 1
		break
print(wyn)


from sys import stdin
(n, m) = map(int, stdin.readline().strip().split())
s = tuple(map(int, stdin.readline().strip().split()))
ma = max(s)
mi = min(s)
dp = [0 for i in range(ma + 3)]
for i in s:
	dp[i] += 1
for i in range(len(dp) - 2, -1, -1):
	dp[i] += dp[i + 1]
x = 0
ans = 0
acum = 0
l = -1
for i in range(len(dp) - 2, mi - 1, -1):
	dp[i] += dp[i + 1]
	if dp[i] - acum > m:
		acum = dp[i + 1]
		ans += 1
		l = i
if l != mi and mi != ma:
	ans += 1
print(ans)


(towers, max_bite_size) = list(map(int, input().strip().split()))
gen = list(map(int, input().strip().split()))
max_height = 2 * 10 ** 5
heights = [0] * max_height
for num in gen:
	heights[num - 1] += 1
num_blocks = 0
num_slices = 0
curr_slice_size = 0
block_sizes = [0] * max_height
for (idx, num) in enumerate(reversed(heights)):
	if num_blocks + num == towers:
		break
	num_blocks += num
	block_sizes[idx] = num_blocks
	if curr_slice_size + num_blocks > max_bite_size:
		num_slices += 1
		curr_slice_size = num_blocks
	else:
		curr_slice_size += num_blocks
if curr_slice_size > 0:
	num_slices += 1
best_so_far = num_slices
num_slices = 0
curr_slice_size = 0
for num in reversed(block_sizes):
	if curr_slice_size + num > max_bite_size:
		num_slices += 1
		curr_slice_size = num
	else:
		curr_slice_size += num
if curr_slice_size > 0:
	num_slices += 1
print(min(num_slices, best_so_far))


from itertools import accumulate
(n, k) = map(int, input().split())
h = sorted(list(map(int, input().split())))
diff = [0 for i in range(h[-1] + 1)]
for i in range(0, n):
	diff[h[i]] += 1
prefix = list(accumulate(reversed(diff)))
slicesum = 0
ans = 0
for i in range(len(diff)):
	if i == len(diff) - h[0] - 1:
		break
	slicesum += prefix[i]
	if slicesum > k:
		ans += 1
		slicesum = prefix[i]
if slicesum > 0:
	ans = ans + 1
print(ans)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
count = [0 for i in range(200001)]
for x in h:
	count[x] += 1
ans = 0
max_h = 200000
cost = 0
while True:
	while count[max_h] == 0:
		max_h -= 1
	if count[max_h] == n:
		if cost != 0:
			ans += 1
		break
	if cost + count[max_h] > k:
		ans += 1
		cost = 0
		continue
	cost += count[max_h]
	count[max_h - 1] += count[max_h]
	count[max_h] = 0
print(ans)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
(maxh, minh) = (max(h), min(h))
dh = maxh - minh
kh = [0] * dh
for cur in h:
	if cur != minh:
		kh[maxh - cur] += 1
for i in range(1, len(kh)):
	kh[i] += kh[i - 1]
ans = s = 0
for cur in kh:
	s += cur
	if s > k:
		ans += 1
		s = cur
if s > 0:
	ans += 1
print(ans)


(n, k) = list(map(int, input().split()))
t = list(map(int, input().split()))
db = [0] * 200008
for i in t:
	db[i] += 1
mn = min(t)
csum = 0
cuts = 0
above = 0
for i in range(200005, mn - 1, -1):
	csum += db[i]
	above += csum
	if above > k or (i == mn and above > csum):
		above = csum
		cuts += 1
print(cuts)


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	(n, k) = cin()
	a = ain()
	a.sort()
	q = min(a)
	an = ans = 0
	p = max(a)
	for i in range(p, -1, -1):
		x = bisect.bisect_right(a, i)
		ans += n - x
		if ans > k:
			an += 1
			ans = n - x
		if i == q:
			break
	if ans != 0:
		an += 1
	print(an)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


x = list(map(int, input().split(' ')))
n = x[0]
k = x[1]
y = list(map(int, input().split(' ')))
mi = min(y)
ma = max(y)
cnt = [0] * 200009
for i in y:
	cnt[i] += 1
pos = 200008
s = 0
c = 0
ans = 0
while True:
	x = s - c * (pos - 1)
	if x > k:
		ma = pos
		s = c * pos
		ans += 1
	pos -= 1
	if pos == mi:
		break
	c += cnt[pos]
	s += pos * cnt[pos]
if ma is not mi:
	ans += 1
print(ans)


(n, k) = map(int, input().split())
ar = list(map(int, input().split()))
N = int(200000.0 + 10)
cnt = [0 for _ in range(N)]
for i in ar:
	cnt[i] += 1
for i in range(N - 2, 0, -1):
	cnt[i] += cnt[i + 1]
cnt[0] = 0
i = N - 1
_sum = 0
ans = 0
while i >= 1:
	if cnt[i] % n == 0 and cnt[i] != 0:
		if _sum != 0:
			ans += 1
		break
	if _sum + cnt[i] <= k:
		_sum += cnt[i]
	else:
		ans += 1
		_sum = cnt[i]
	i -= 1
print(ans)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
l = []
for i in range(n - 1, 0, -1):
	if h[i] != h[i - 1]:
		for _ in range(h[i] - h[i - 1]):
			l.append(n - i)
if len(l) == 0:
	print(0)
else:
	p = 0
	r = 1
	for i in l:
		if p + i <= k:
			p += i
		else:
			r += 1
			p = i
	print(r)


(n, k1) = map(int, input().split())
h = list(map(int, input().split()))
maxx = max(h)
a = []
h.sort()
t = 1
for i in range(n - 1, 0, -1):
	if h[i] != h[i - 1]:
		if len(a) != 0:
			k = len(a) - 1
			for j in range(h[i] - h[i - 1]):
				a.append(t + a[k])
		else:
			for j in range(h[i] - h[i - 1]):
				a.append(t)
		t = 1
	else:
		t += 1
sum1 = 0
num = 0
for i in range(len(a)):
	sum1 += a[i]
	if i != len(a) - 1 and sum1 + a[i + 1] > k1:
		sum1 = 0
		num += 1
if len(a) != 0:
	num += 1
print(num)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
s = 0
price = 0
h = sorted(h)
h = list(reversed(h))
height = h[0]
for i in range(n):
	while h[i] < height:
		height -= 1
		if price + i > k:
			s += 1
			price = i
		else:
			price += i
if price > 0:
	s += 1
print(s)


[n, k] = [int(i) for i in input().split()]
h = [0 for i in range(2 * 10 ** 5 + 1)]
for i in input().split():
	h[int(i)] += 1
h[0] = n
ans = 0
cur = 0
ij = 0
for i in range(2 * 10 ** 5, -1, -1):
	ij += h[i]
	if ij == n:
		ans += cur != 0
		print(ans)
		exit(0)
	if cur + ij <= k:
		cur += ij
	else:
		ans += 1
		cur = ij


(n, k) = map(int, input().split())
level = {}
for t in input().split():
	h = int(t)
	level[h] = level.get(h, 0) + 1
(m, c, base, prev) = (1, 0, 0, max(level))
for h in sorted(level, reverse=True):
	while c + (prev - h) * base > k:
		prev -= (k - c) // base
		c = 0
		m += 1
	c += (prev - h) * base
	prev = h
	base += level[h]
print(0 if len(level) == 1 else m)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
l = []
arr.sort()
arr.reverse()
for i in range(n - 1):
	for j in range(arr[i] - arr[i + 1]):
		l.append(i + 1)
curr = 0
count = 0
for i in range(len(l)):
	if curr + l[i] > k:
		curr = l[i]
		count += 1
	else:
		curr += l[i]
if curr != 0:
	count += 1
print(count)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
z = [0] * 300000
for i in a:
	z[i] += 1
ma = max(a)
mi = min(a)
count = 0
t = z[ma]
s = t
if ma == mi + 1:
	print(1)
else:
	while ma > mi + 1:
		while s + t + z[ma - 1] <= k and ma >= mi:
			ma -= 1
			t += z[ma]
			s += t
		s = 0
		count += 1
	print(count)


from __future__ import division, print_function
import collections

def main():
	import sys
	data = iter(map(int, sys.stdin.buffer.read().decode('ascii').split()))
	n = next(data)
	k = next(data)
	hsize = 200000 + 2
	h = [0] * hsize
	hmin = hsize
	hmax = 0
	for _ in range(n):
		val = next(data)
		h[val] += 1
		hmin = min(hmin, val)
		hmax = max(hmax, val)
	h = h[0:hmax + 1]
	for val in range(hmin, hmax + 1):
		h[val] = h[val] + h[val - 1]
	kk = 0
	res = 0
	for val in range(hmin + 1, hmax + 1):
		count = h[hmax] - h[val - 1]
		if kk >= count:
			kk -= count
		else:
			kk = k - count
			res += 1
	print(res)
	return 0
main()


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
m = max(a)
h = []
for i in range(m + 2):
	h.append(0)
for i in range(n):
	h[1] += 1
	h[a[i] + 1] -= 1
for i in range(1, m + 1):
	h[i] += h[i - 1]
cur = 0
res = 0
for i in range(m, 0, -1):
	if h[i] < n:
		if cur + h[i] <= k:
			cur += h[i]
		else:
			res += 1
			cur = h[i]
if cur > 0:
	res += 1
print(res)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
heights = []
counter = arr[0]
for i in range(n):
	while arr[i] >= counter:
		heights.append(n - i)
		counter += 1
heights.reverse()
ans = 0
container = 0
for i in range(len(heights) - 1):
	if heights[i] + container <= k:
		container += heights[i]
	else:
		container = heights[i]
		ans += 1
if container > 0:
	ans += 1
print(ans)


from sys import stdin, stdout

def main():
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	h_cnt = [0 for i in range(200005)]
	mx = 1
	for i in range(n):
		h_cnt[a[i]] += 1
		mx = max(mx, a[i])
	tmp = mx
	while tmp:
		if h_cnt[tmp] == n:
			break
		h_cnt[tmp] += h_cnt[tmp + 1]
		tmp -= 1
	tmp = 0
	ans = 0
	while mx:
		if h_cnt[mx] == n:
			break
		if h_cnt[mx] + tmp > k:
			tmp = 0
			ans += 1
		else:
			tmp += h_cnt[mx]
			mx -= 1
	if tmp:
		ans += 1
	print(ans)
main()


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
d = {}
for x in l:
	d[x] = d.get(x, 0) + 1
ma = max(d)
mi = min(d)
k = 0
act = 0
for i in range(ma, mi, -1):
	if act + d[i] <= m:
		act += d[i]
	else:
		act = d[i]
		k += 1
	d[i - 1] = d.get(i - 1, 0) + d[i]
if act > 0:
	k += 1
print(k)


import sys
import os

def solve(n, k, h):
	h.sort()
	top = h[len(h) - 1]
	s = [n] * top
	c = 0
	for i in range(top):
		s[i] = n - c
		while c < n and h[c] == i + 1:
			c += 1
	pack = 0
	result = 0
	c = top - 1
	while s[c] < n:
		diff = s[c]
		c -= 1
		if pack + diff <= k:
			pack += diff
		else:
			pack = diff
			result += 1
	if pack > 0:
		result += 1
	return result

def main():
	(n, k) = (int(x) for x in input().split())
	h = list((int(x) for x in input().split()))
	print(solve(n, k, h))

def __starting_point():
	main()
__starting_point()


import sys
input = sys.stdin.readline
MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input().strip('\n'))
si = lambda : input().strip('\n')
dgl = lambda : list(map(int, input().strip('\n')))
f = lambda : map(int, input().strip('\n').split())
il = lambda : list(map(int, input().strip('\n').split()))
ls = lambda : list(input().strip('\n'))
let = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(1):
	(n, k) = f()
	l = il()
	mn = min(l)
	mx = max(l)
	ht = [0] * (mx + 2)
	for i in l:
		ht[mn + 1] += 1
		ht[i + 1] -= 1
	for i in range(1, mx + 2):
		ht[i] += ht[i - 1]
	sm = 0
	ans = 0
	for i in range(mx + 1, mn - 1, -1):
		if sm + ht[i] > k:
			ans += 1
			sm = ht[i]
		else:
			sm += ht[i]
	print(ans + (sm > 0))


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
MOD = 1000000007

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, k) = value()
a = array()
C = Counter(a)
a = sorted(set(a))
level = []
over = 0
for i in range(min(a), max(a) + 1):
	level.append(n - over)
	over += C[i]
level = level[::-1]
level = level[:-1]
ans = 0
cur = 0
for i in level:
	if cur + i > k:
		cur = 0
		ans += 1
	cur += i
ans += cur > 0
print(ans)


import sys
from bisect import *

def rint():
	return map(int, sys.stdin.readline().split())
(n, k) = rint()
h = list(rint())
h.sort()
hmin = h[0]
h = [h[i] - hmin for i in range(n)]
hmax = h[-1]
h.sort(reverse=True)
hh = [0] * (hmax + 1)
for i in range(n - 1):
	for j in range(h[i + 1] + 1, h[i] + 1):
		hh[j] += i + 1
s = 0
cnt = 0
for i in range(len(hh) - 1, 0, -1):
	if s + hh[i] <= k:
		s += hh[i]
	else:
		cnt += 1
		s = hh[i]
if s > 0:
	cnt += 1
print(cnt)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
mi = min(h)
ma = max(h)
h = sorted(h, reverse=True)
rec = [0] * (ma + 1)
for i in range(n):
	rec[h[i]] += 1
for i in range(ma - 1, -1, -1):
	rec[i] += rec[i + 1]
cnt = 0
tmp = 0
i = ma
while i > mi:
	while i > mi and tmp + rec[i] <= k:
		tmp += rec[i]
		i -= 1
	tmp = 0
	cnt += 1
print(cnt)


import bisect as bs
(n, k) = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
if h[0] == h[-1]:
	print(0)
else:
	b = h[-1] - h[0]
	l = [0] * b
	for i in range(b):
		l[i] = n - bs.bisect_right(h, h[-1] - i - 1)
	sm = 0
	c = 0
	for i in range(b):
		sm += l[i]
		if sm > k:
			sm = l[i]
			c += 1
	c += 1
	print(c)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
from math import gcd
import io
import os
from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
mm = 200009
(n, k) = map(int, input().split())
l = [int(x) for x in input().split()]
ll = [0] * mm
for i in l:
	ll[i] += 1
ans = 0
mmm = min(l)
cap = 0
i = mm - 1
h = max(l)
ss = 0
while True:
	x = ss - cap * (i - 1)
	if x > k:
		ans += 1
		h = i
		ss = i * cap
	i -= 1
	if i == mmm:
		break
	cap += ll[i]
	ss += ll[i] * i
if i != h:
	ans += 1
print(ans)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
maxx = max(l)
minn = min(l)
deta = maxx - minn
a = [0] * deta
for i in range(n):
	res = maxx - l[i]
	if res < deta:
		a[res] += 1
s = 0
for i in range(deta):
	s += a[i]
	a[i] = s
cnt = s = 0
for i in range(deta):
	s += a[i]
	if s > k:
		cnt += 1
		s = a[i]
if s != 0:
	cnt += 1
print(cnt)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
N = int(200000.0) + 2
highest = 0
lowest = N
tower = [0] * N
for i in h:
	highest = max(highest, i)
	lowest = min(lowest, i)
	tower[i] += 1
pos = N - 1
res = 0
total = 0
c = 0
while True:
	x = total - c * (pos - 1)
	if x > k:
		res += 1
		highest = pos
		total = pos * c
	pos -= 1
	if pos == lowest:
		break
	c += tower[pos]
	total += tower[pos] * pos
if highest != lowest:
	res += 1
print(res)


(n, k) = map(int, input().split())
a = [0] * 1000000
b = [0] * 1000000
pos = 0
ans = 0
res = 0
for i in input().split():
	a[int(i) + 1] -= 1
	a[1] += 1
	pos = max(pos, int(i))
for i in range(pos + 1):
	a[i] += a[i - 1]
	if a[i] == n:
		ans = i
ind = pos
for i in range(pos, ans - 1, -1):
	b[i] = a[i] + b[i + 1]
	if b[i] > k:
		res += 1
		b[i] = a[i]
		ind = i
if b[ind] <= k and b[ind] < n:
	res += 1
print(res)


from sys import stdin
input = stdin.readline
(n, k) = map(int, input().split())
h = list(map(int, input().split()))
mh = min(h)
Mh = max(h)
d = [0] * (Mh + 1)
for i in range(n):
	d[h[i]] += 1
for i in range(Mh)[::-1]:
	d[i] += d[i + 1]
if len(set(h)) == 1:
	print(0)
	exit()
cnt = 1
s = 0
now_height = Mh
while now_height > 0 and d[now_height] != n:
	if s + d[now_height] <= k:
		s += d[now_height]
	else:
		cnt += 1
		s = d[now_height]
	now_height -= 1
print(cnt)


from __future__ import print_function
from itertools import permutations as perm
from collections import *
from sys import stdin
from bisect import *
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(n, k) = gil()
f = [0] * (int(200000.0) + 1)
r = 1
mi = inf
for v in gil():
	r = max(r, v)
	mi = min(mi, v)
	f[v] += 1
if f[mi] == n:
	print(0)
	exit()
ans = 0
cnt = 0
sm = 0
while r >= mi:
	if sm - cnt * r <= k:
		cnt += f[r]
		sm += r * f[r]
		r -= 1
	else:
		ans += 1
		r += 1
		f[r] = cnt
		cnt = 0
		sm = 0
print(ans + (1 if sm else 0))


import sys
import math as mt
input = sys.stdin.buffer.readline
t = 1
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	mini = min(l[:])
	d = [0] * 200002
	for i in range(n):
		d[l[i]] += 1
	ans = 0
	cost = 0
	i = 200000
	while i >= mini:
		if cost + d[i + 1] <= k:
			cost += d[i + 1]
			d[i] += d[i + 1]
		else:
			cost = d[i + 1]
			d[i] += d[i + 1]
			ans += 1
		i -= 1
	if cost != 0:
		ans += 1
	print(ans)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
d = 0
l = h[n - 1]
j = n - 1
s = 0
while h[j] != h[0]:
	if h[j - 1] != h[j]:
		for i in range(l, h[j - 1], -1):
			if s + n - j > k:
				d += 1
				s = n - j
			else:
				s += n - j
		l = h[j - 1]
	j -= 1
if s != 0:
	d += 1
print(d)


(n, k) = map(int, input().split())
x = [int(v) for v in input().split()]
l = [0] * 200002
for i in range(n):
	l[x[i]] += 1
(M, m) = (max(x), min(x))
ans = 0
temp = 0
for i in range(M, m, -1):
	if temp + l[i] > k:
		ans += 1
		temp = 0
	temp += l[i]
	l[i - 1] += l[i]
if temp > 0:
	ans += 1
print(ans)


def cell(num):
	if int(num) < num:
		return num + 1
	return num
(n, k) = list(map(int, input().split()))
hi = list(map(int, input().split()))
hi.sort()
num = 0
if n == 1:
	print(0)
else:
	height = hi[-1]
	sumHeight = 0
	num2 = 1
	for i in range(n - 2, -1, -1):
		sumHeight2 = sumHeight + num2 * (height - hi[i])
		if sumHeight2 == k:
			num += 1
			sumHeight = 0
		elif sumHeight2 > k:
			num5 = k // num2
			j = height
			num6 = sumHeight
			while num6 <= k:
				num6 += num2
				j -= 1
			num += 1
			num += (j + 1 - hi[i]) // num5
			sumHeight = (j + 1 - hi[i]) % num5 * num2
		else:
			sumHeight = sumHeight2
		height = hi[i]
		num2 += 1
	if sumHeight > 0:
		num += 1
	print(num)


from itertools import groupby
(n, k) = [int(i) for i in input().split()]
h = sorted((int(i) for i in input().split()), reverse=True)
groups = [[v, len(list(g))] for (v, g) in groupby(h)]
slices = 0
while len(groups) > 1:
	slices += 1
	removed = 0
	while len(groups) > 1 and removed + groups[0][1] <= k:
		removed += groups[0][1]
		groups[0][0] -= 1
		if groups[0][0] == groups[1][0]:
			groups[0][1] += groups[1][1]
			groups.pop(1)
print(slices)


(towersNum, slices) = map(int, input().split())
towers = list(map(int, input().split()))
towers.sort(reverse=True)
c = 0
last = towers[-1]
first = towers[0]
next = 1
m = 0
while first != last:
	while first == towers[next]:
		next += 1
	if c + next > slices:
		m += 1
		c = next
	else:
		c += next
	first -= 1
if c > 0:
	m += 1
print(m)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
a.append(0)
b = [0] * (a[0] + 1)
elem = a[0]
value = 0
i = 0
while i < n + 1:
	if a[i] == elem:
		value += 1
		i += 1
	else:
		b[elem] = value
		elem -= 1
b.reverse()
b.pop()
sum = k
ans = 0
i = 0
while b[i] != b[-1]:
	sum = k
	while b[i] != b[-1] and sum >= b[i]:
		sum -= b[i]
		i += 1
	ans += 1
print(ans)


def main(n, k, heights):
	min_height = min(heights)
	heights = [h - min_height for h in heights]
	heights = sorted(heights)
	slices = []
	s_height = heights[0]
	j = 0
	for h in range(heights[-1] + 1):
		while h > heights[j]:
			j += 1
		slices.append(len(heights) - j)
	slices = list(reversed(slices))[0:-1]
	(part_sum, cut) = (0, 0)
	for c in slices:
		if part_sum + c > k:
			part_sum = 0
			cut += 1
		part_sum += c
	if part_sum > 0:
		cut += 1
	print(cut)
(n, k) = map(int, input().split())
heights = list(map(int, input().split()))
main(n, k, heights)


I = lambda : int(input())
ID = lambda : map(int, input().split())
IL = lambda : list(ID())
(n, k) = ID()
a = IL()
a.sort()
mini = a[0]
for i in range(n):
	a[i] -= mini
d = 1
val = ans = i = 0
while i != n:
	if a[i] >= d:
		if val + n - i > k:
			ans += 1
			val = n - i
		else:
			val += n - i
		d += 1
	else:
		i += 1
if val > 0:
	print(ans + 1)
else:
	print(ans)


(n, k) = map(int, input().split())
H = list(map(int, input().split()))
from collections import Counter
counter = Counter(H)
key = list(counter.keys())
key.sort()
key.reverse()
HEIGHTS = [0 for i in range(key[0] + 1)]
for i in key:
	HEIGHTS[i] += counter[i]
for i in range(key[0] - 1, 0, -1):
	HEIGHTS[i] = HEIGHTS[i] + HEIGHTS[i + 1]
	if HEIGHTS[i] == n:
		HEIGHTS[i] = 0
		break
if HEIGHTS[key[0]] == n:
	HEIGHTS[key[0]] = 0
HEIGHTS.reverse()
HEIGHTS.append(0)
x = key[0] + 1
i = 0
count = 0
box = 0
while i <= x:
	box += HEIGHTS[i]
	if box == k:
		count += 1
		box = 0
		i += 1
	elif box > k:
		count += 1
		box = 0
	else:
		i += 1
if box > 0:
	count += 1
print(count)


import sys
lines = sys.stdin.readlines()
(n, k) = map(int, lines[0].strip().split(' '))
nums = list(map(int, lines[1].strip().split(' ')))
(minH, maxH) = (min(nums), max(nums))
heights = [0 for _ in range(maxH - minH + 1)]
for num in nums:
	heights[num - minH] += 1
for i in range(maxH - minH - 1, -1, -1):
	heights[i] += heights[i + 1]
res = 0
curr = 0
for i in range(maxH - minH, 0, -1):
	if curr + heights[i] <= k:
		curr += heights[i]
	else:
		res += 1
		curr = heights[i]
if curr != 0:
	res += 1
print(res)


def main():
	(n, k) = map(lambda x: int(x), input().split(' '))
	h = list(map(lambda x: int(x), input().split(' ')))
	num = [0 for i in range(max(h) + 5)]
	for i in h:
		num[i] += 1
	ans = 0
	now = max(h)
	now_cost = 0
	now_tower = 0
	while now:
		if num[now] + now_cost <= k:
			pass
		else:
			ans += 1
			now_cost = 0
		if num[now] == n:
			break
		now_cost += num[now]
		now -= 1
		num[now] += num[now + 1]
	if now_cost != 0:
		ans += 1
	print(ans)
main()


(n, m) = map(int, input().split())
h = [int(i) for i in input().split(' ')]
h.sort(reverse=True)
pre_h = h[0]
ans = 0
cubes = 0
towers = 0
for i in range(0, n):
	if cubes + (pre_h - h[i]) * towers < m:
		cubes += (pre_h - h[i]) * towers
		towers += 1
		pre_h = h[i]
		if i == n - 1 and cubes != 0:
			ans += 1
		continue
	cha = pre_h - h[i]
	cha -= (m - cubes) // towers
	ans += 1
	ans += cha // (m // towers)
	cubes = (cha - cha // (m // towers) * (m // towers)) * towers
	towers += 1
	pre_h = h[i]
	if i == n - 1 and cubes != 0:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
hMax = 0
hMin = 10 ** 9
for hi in h:
	hMax = max(hMax, hi)
	hMin = min(hMin, hi)
cnt = [0] * (hMax + 1)
for hi in h:
	cnt[hi] += 1
c = 0
sum = 0
curH = hMax
slice = 0
while curH > hMin:
	ci = cnt[curH]
	c += ci
	if k < sum + c:
		slice += 1
		sum = 0
	sum += c
	curH -= 1
if sum > 0:
	slice += 1
print(slice)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
tall = max(h)
heights = [0] * tall
for i in range(n):
	heights[h[i] - 1] += 1
heights.reverse()
j = [heights[0]]
for i in range(tall - 1):
	j.append(j[-1] + heights[i + 1])
fin = min(h)
at = 0
avail = k
ops = 1
while at < tall - fin:
	if j[at] > avail:
		ops += 1
		avail = k - j[at]
		at += 1
	else:
		avail -= j[at]
		at += 1
lame = True
for i in range(len(h) - 1):
	if h[i] != h[i + 1]:
		lame = False
		break
if lame:
	print(0)
else:
	print(ops)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
p = [0] * (2 * 10 ** 5 + 1)
m = -1
for i in range(n):
	x = l[i]
	m = max(x, m)
	p[x] += 1
high = m
m = m - 1
while m > 0:
	p[m] += p[m + 1]
	m -= 1
s = set()
d = {}
for i in range(1, high + 1):
	d[i] = p[i]
ans = 0
e = high
tcnt = 0
flag = 0
d[0] = n
while flag == 0 and e > -1:
	if d[e] == n:
		if tcnt > 0:
			ans += 1
		flag = 1
		break
	if tcnt + d[e] <= k:
		tcnt += d[e]
		val = d[e]
	else:
		ans += 1
		tcnt = d[e]
	e -= 1
print(ans)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()
(n, k) = map(int, minp().split())
a = list(map(int, minp().split()))
a.sort(reverse=True)
i = 0
px = a[0]
s = k + 1
r = 0
pc = 0
c = 0
z = []
while i < n:
	x = a[i]
	while i < n and a[i] == x:
		c += 1
		i += 1
	while px != x:
		z.append(pc)
		px -= 1
	pc = c
while px != -1:
	z.append(pc)
	px -= 1
if len(z) != 0:
	ze = z[-1]
	while len(z) != 0 and z[-1] == ze:
		z.pop()
for i in z:
	px -= 1
	if s + i > k:
		s = i
		r += 1
	else:
		s += i
print(r)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
(n, k) = L()
A = L()
A.sort()
pref = [0 for i in range(A[-1] + 2)]
for h in A:
	pref[1] += 1
	pref[1 + h] -= 1
for i in range(1, A[-1] + 2):
	pref[i] += pref[i - 1]
cnt = 0
i = -1
while pref[i - 1] != n:
	curr = 0
	while pref[i - 1] != n and curr + pref[i - 1] <= k:
		i -= 1
		curr += pref[i]
	cnt += 1
print(cnt)
endtime = time.time()


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
(n, k) = ilele()
H = alele()
H.sort()
m = H[0]
layer = [0] * (H[-1] + 1)
for i in range(len(layer) - 1):
	x = bisect.bisect_left(H, i + 1)
	layer[i + 1] = n - x
slice = 0
temp = 0
for i in range(len(layer) - 1, m, -1):
	if temp + layer[i] <= k:
		temp += layer[i]
	else:
		slice += 1
		temp = layer[i]
if temp != 0:
	slice += 1
print(slice)


(n, k) = map(int, input().split())
mas = list(map(int, input().split()))
di = {i: 0 for i in range(1, 200006)}
(a, b) = (0, 300000)
for (i, x) in enumerate(mas):
	if x > a:
		a = x
	if x < b:
		b = x
	di[x] += 1
(res, q, w) = (0, 0, 0)
e = a
if e == b:
	print(0)
else:
	for i in range(e - b):
		t = di[a]
		if q + t + w <= k:
			q += t + w
			a -= 1
			w += t
		else:
			res += 1
			q = t + w
			a -= 1
			w += t
	print(res + 1)


(numOfTowers, numOfOperation) = map(int, input().split())
towerheights = list(map(int, input().split()))
towerheights.sort(reverse=True)
counter = 0
lowerheight = towerheights[-1]
higherheight = towerheights[0]
nextheightindex = 1
minNumOfgoodSlices = 0
while higherheight != lowerheight:
	while higherheight == towerheights[nextheightindex]:
		nextheightindex += 1
	if counter + nextheightindex > numOfOperation:
		minNumOfgoodSlices += 1
		counter = nextheightindex
	else:
		counter += nextheightindex
	higherheight -= 1
if counter > 0:
	minNumOfgoodSlices += 1
print(minNumOfgoodSlices)


from collections import Counter
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
min_ = min(arr)
max_ = max(arr)
heights = [0 for x in range(max_)]
sum = 0
count = 0
A = Counter(arr)
for ind in range(max_ - 1, -1, -1):
	if ind + 1 != min_:
		sum += A[ind + 1]
		A[ind] += A[ind + 1]
		if not sum <= k:
			sum = A[ind + 1]
			count += 1
	elif sum > 0:
		count += 1
		break
print(count)


import sys
import math
MAXNUM = math.inf
MINNUM = -1 * math.inf
ASCIILOWER = 97
ASCIIUPPER = 65

def getInt():
	return int(sys.stdin.readline().rstrip())

def getInts():
	return map(int, sys.stdin.readline().rstrip().split(' '))

def getString():
	return sys.stdin.readline().rstrip()

def printOutput(ans):
	sys.stdout.write()
	pass

def solve(b, k):
	pftree = [0 for _ in range(max(b) + 1)]
	base = min(b)
	for ele in b:
		pftree[ele] += 1
	for i in reversed(range(0, len(pftree) - 1)):
		pftree[i] = pftree[i] + pftree[i + 1]
	cur = len(pftree) - 1
	cut = 0
	numcuts = 0
	while cur != base:
		if pftree[cur] + cut <= k:
			cut += pftree[cur]
			pftree[cur] = 0
			cur -= 1
		else:
			cut = 0
			numcuts += 1
	if cut > 0:
		numcuts += 1
	print(numcuts)

def readinput():
	(n, k) = getInts()
	boxes = list(getInts())
	solve(boxes, k)
readinput()


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys

def canSliceToHeight(highest, targetHeight, start, heights, maxSliceCount):
	total = (highest - targetHeight) * start
	if total > maxSliceCount:
		return False
	for i in range(start, len(heights)):
		h = heights[i]
		if h <= targetHeight:
			break
		total += heights[i] - targetHeight
	return total <= maxSliceCount

def findNextHighest(currentHighest, start, heights, maxSliceCount):
	(lo, hi) = (0, currentHighest)
	while lo < hi:
		m = (lo + hi) // 2
		if canSliceToHeight(currentHighest, m, start, heights, maxSliceCount):
			hi = m
		else:
			lo = m + 1
	return lo

def solve(N, K, H):
	H.sort(reverse=True)
	target = H[-1]
	steps = 0
	start = 1
	highest = H[0]
	done = False
	while highest > target and (not done):
		nextHighest = findNextHighest(highest, start, H, K)
		if H[start] < nextHighest:
			slicedHeightPerStep = highest - nextHighest
			localSteps = (highest - H[start]) // slicedHeightPerStep
			steps += localSteps
			highest -= slicedHeightPerStep * localSteps
		else:
			nextStart = start
			for i in range(start, N):
				if H[i] < nextHighest:
					nextStart = i
					break
			start = nextStart
			steps += 1
			highest = nextHighest
	return steps
(N, K) = map(int, input().split())
H = [int(x) for x in input().split()]
print(solve(N, K, H))


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
chop = min(a)
a = [x - chop for x in a]
slices = 0
h_greater = {}
a = sorted(a)[::-1]
pos = 1
for h in a:
	h_greater[h] = pos
	pos += 1
heights = []
prev = h_greater[max(a)]
for i in range(max(a), 0, -1):
	if i in h_greater:
		heights.append(h_greater[i])
		prev = h_greater[i]
	else:
		heights.append(prev)
slices = 1
count = 0
for h in heights:
	if count + h > k:
		count = 0
		slices += 1
	count += h
flag = True
for ele in a:
	if ele != 0:
		flag = False
		break
if not flag:
	print(slices)
else:
	print(0)


(n, k) = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
mih = min(h)
mah = max(h)
if mah == mih:
	print(0)
	return
cotam = dict()
lotam = list()
sotam = set()
for th in h:
	if th > mih:
		if th in sotam:
			cotam[th] += 1
		else:
			sotam.add(th)
			lotam.append(th)
			cotam[th] = 1
lotam.sort(reverse=True)
sc = 0
cc = 0
rk = 0
for i in range(len(lotam)):
	ch = lotam[i]
	nh = mih if i >= len(lotam) - 1 else lotam[i + 1]
	cc += cotam[ch]
	if rk >= cc:
		hrbrk = min(ch - nh, rk // cc)
		rk -= cc * hrbrk
		ch -= hrbrk
	while ch > nh:
		hrbk = min(ch - nh, k // cc)
		sc += 1
		ch -= hrbk
		rk = k - hrbk * cc
print(sc)


(n, k) = map(int, input().split())
arr = list(sorted(map(int, input().split()), reverse=True))
dup = set()
recs = dict()
for (idx, v) in enumerate(arr):
	dup.add(v)
	recs[v] = idx + 1
height = arr[0]
weight = recs[height]
res = list()
left = ans = 0
for i in range(height, 0, -1):
	if i in recs:
		weight = recs[i]
	if weight != n:
		if left + weight > k:
			ans += 1
			left = weight
		elif left + weight == k:
			ans += 1
			left = 0
		else:
			left += weight
	else:
		break
if left != 0:
	ans += 1
print(ans)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
hs1 = [0 for _ in range(a[-1])]
for i in range(n):
	hs1[a[i] - 1] += 1
pluser = 0
hs = [0 for _ in range(a[-1])]
for i in range(a[-1]):
	pluser += hs1[a[-1] - i - 1]
	hs[a[-1] - i - 1] = pluser
floor = a[-1] - 1
ans = 0
count = 0
while floor > a[0] - 1:
	while floor > a[0] - 1 and count + hs[floor] <= k:
		count += hs[floor]
		floor -= 1
	ans += 1
	count = 0
print(ans)


from sys import stdin, stdout

def main():
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	h_cnt = [0 for i in range(200005)]
	(mn, mx) = (200000, 1)
	for i in range(n):
		h_cnt[a[i]] += 1
		mx = max(mx, a[i])
	tmp = mx
	while tmp:
		if h_cnt[tmp] == n:
			break
		h_cnt[tmp] += h_cnt[tmp + 1]
		tmp -= 1
	tmp = 0
	ans = 0
	while mx:
		if h_cnt[mx] == n:
			break
		if h_cnt[mx] + tmp > k:
			tmp = 0
			ans += 1
		else:
			tmp += h_cnt[mx]
			mx -= 1
	if tmp:
		ans += 1
	stdout.write('%d' % ans)
	del n, k, a, h_cnt
main()


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
d = {}
h.sort(reverse=True)
for i in h:
	try:
		d[i] += 1
	except KeyError:
		d[i] = 1
h = list(d.keys())
h.sort(reverse=True)
s = 0
to = 0
for i in range(1, len(h)):
	d[h[i]] = d[h[i]] + d[h[i - 1]]
for i in range(len(h)):
	a = d[h[i]]
	if a == n:
		ad = d[h[i - 1]]
		for j in range(h[i - 1] - 1, h[i], -1):
			if to <= k and to + ad > k:
				s += 1
				to = ad
			else:
				to += ad
		break
	elif i == 0:
		to += a
	else:
		ad = d[h[i - 1]]
		for j in range(h[i - 1] - 1, h[i] - 1, -1):
			if j == h[i]:
				ad = a
			if to <= k and to + ad > k:
				to = ad
				s += 1
			else:
				to += ad
if to > 0:
	s += 1
print(s)


(n, k) = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
h.sort()
hh = h[0]
for i in range(len(h)):
	h[i] -= hh
g = [0] * h[-1]
last = 0
for i in range(1, len(h)):
	if h[i] > h[i - 1]:
		for j in range(last, h[i]):
			g[j] = n - i
			last = h[i]
g.reverse()
s = 0
ans = 0
for i in range(len(g)):
	if s + g[i] > k:
		ans += 1
		s = g[i]
	else:
		s += g[i]
if s > 0:
	ans += 1
print(ans)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
if h == [h[0]] * n:
	print(0)
	exit()
imos = [0] * (2 * 10 ** 5 + 100)
for hi in h:
	imos[1] += 1
	imos[hi + 1] -= 1
for i in range(1, 2 * 10 ** 5 + 100):
	imos[i] += imos[i - 1]
(max_h, min_h) = (max(h), min(h))
ans = 1
cnt = 0
for i in range(max_h, min_h, -1):
	if cnt + imos[i] > k:
		ans += 1
		cnt = imos[i]
	else:
		cnt += imos[i]
print(ans)


a = list(map(int, input().split()))
l = list(map(int, input().split()))
m = max(l)
mi = m - min(l)
li = [0] * mi
for i in range(a[0]):
	v = m - l[i]
	if v < mi:
		li[v] += 1
le = len(li)
s = 0
for i in range(le):
	s += li[i]
	li[i] = s
c = 0
s = 0
for i in range(le):
	s = s + li[i]
	if s > a[1]:
		c += 1
		s = li[i]
if s > 0:
	c += 1
print(c)


I = lambda : map(int, input().split())
(n, k) = I()
a = sorted(I())
(l, q, w) = ([], 0, 0)
for i in range(1, n):
	n -= 1
	if a[i] > a[i - 1]:
		l += [n] * (a[i] - a[i - 1])
l.sort()
for i in range(len(l)):
	if q + l[i] == k:
		w += 1
		q = 0
	elif q + l[i] > k:
		w += 1
		q = l[i]
	else:
		q += l[i]
print(w + (q > 0))


(n, k) = map(int, input().split())
s = [0 for i in range(2 * 10 ** 5 + 1)]
for i in [int(i) for i in input().split()]:
	s[i] += 1
s[0] = n
h = 0
m = 0
c = 0
for i in range(2 * 10 ** 5, -1, -1):
	c += s[i]
	if c == n:
		h += m != 0
		break
	if m + c > k:
		h += 1
		m = c
	else:
		m += c
print(h)


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ma = max(a)
	(h, s, su) = ([0] * (ma + 1), 0, 0)
	for i in a:
		h[i] += 1
	for i in range(ma, -1, -1):
		if h[i] == n:
			s += su > 0
			break
		if su + h[i] <= k:
			su += h[i]
		else:
			s += 1
			su = h[i]
		h[i - 1] += h[i]
	print(s)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
ma = max(L)
f = [0] * (ma + 1)
for i in L:
	f[i] += 1
for i in reversed(range(ma)):
	f[i] = f[i] + f[i + 1]
c = 0
s = 0
if f[ma] == n:
	print(0)
	quit()
for i in reversed(range(ma + 1)):
	if f[i] == n:
		break
	s += f[i]
	if s > k:
		c += 1
		s = f[i]
print(c + 1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
h = [0 for i in range(max(a) + 1)]
for ai in a:
	h[ai] += 1
for i in range(1, len(h)):
	h[i] += h[i - 1]
tp = len(h) - 1
bp = 0
while h[bp] == 0:
	bp += 1
cuts = 0
while tp != bp:
	c = 0
	while tp != bp and c + h[-1] - h[tp - 1] <= k:
		c += h[-1] - h[tp - 1]
		tp -= 1
	cuts += 1
print(cuts)


def read():
	return [int(v) for v in input().split()]

def main():
	(n, k) = read()
	a = read()
	min_level = min(a)
	max_level = max(a)
	if min_level == max_level:
		print(0)
		return
	heights = [0] * (max_level + 1)
	for i in range(n):
		heights[a[i] - min_level] += 1
	for i in range(max_level - 2, -1, -1):
		heights[i] += heights[i + 1]
	cuts = 0
	last_cut = max_level
	while last_cut > 0:
		s = 0
		while s + heights[last_cut] <= k and last_cut > 0:
			s += heights[last_cut]
			last_cut -= 1
		cuts += 1
	print(cuts)
main()


while True:
	try:

		def solution(k):
			buld = list(map(int, input().split()))
			Max = 0
			Min = 10 ** 12
			stats = [0] * (3 * 10 ** 5)
			for i in range(len(buld)):
				Max = max(Max, buld[i])
				Min = min(Min, buld[i])
				stats[buld[i]] += 1
			for i in range(Max, Min - 1, -1):
				stats[i] += stats[i + 1]
			sum = 0
			step = 0
			for i in range(Max, Min, -1):
				if sum + stats[i] > k:
					sum = 0
					step += 1
				sum += stats[i]
			if sum:
				step += 1
			print(step)
		if __name__ == '__main__':
			(n, k) = map(int, input().split())
			solution(k)
	except EOFError:
		break


(n, k) = [int(x) for x in input().split()]
d = {}
ns = [int(x) for x in input().split()]
minn = min(ns)
ns = [x - minn for x in ns]
for c in ns:
	if c in d:
		d[c] += 1
	else:
		d[c] = 1

def eat(i, need):
	al = (ns[i] - ns[i + 1]) * d[ns[i]]
	if al > need:
		thick = d[ns[i]]
		eath = need // thick
		d[ns[i] - eath] = d[ns[i]]
		ns[i] -= eath
		return (i, 0)
	if al == need:
		d[ns[i + 1]] += d[ns[i]]
		return (i + 1, 0)
	if al < need:
		d[ns[i + 1]] += d[ns[i]]
		return (i + 1, need - al)
ns = list(d.keys())
ns.sort(reverse=True)
ans = 0
i = 0
newn = k
while i < len(ns) - 1:
	(i, newn) = eat(i, newn)
	if newn > 0 and i >= len(ns) - 1:
		ans += 1
		break
	if newn == 0:
		ans += 1
		newn = k
print(ans)


import math as ma
import sys
from decimal import Decimal as dec
from itertools import permutations

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

def modInverse(a, m):
	m0 = m
	y = 0
	x = 1
	if m == 1:
		return 0
	while a > 1:
		q = a // m
		t = m
		m = a % m
		a = t
		t = y
		y = x - q * y
		x = t
	if x < 0:
		x = x + m0
	return x

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

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(n, k) = num()
h = li()
a = [0] * (max(h) + 5)
mx = max(h)
mn = min(h)
fo = True
for i in range(1, n):
	if h[i] != h[i - 1]:
		fo = False
		break
for i in range(n):
	a[0] += 1
	a[h[i] + 1] -= 1
for i in range(1, len(a)):
	a[i] = a[i] + a[i - 1]
s = a[mx]
cc = 0
fl = False
for i in range(mx - 1, mn, -1):
	if s + a[i] > k:
		fl = True
		s = a[i]
		cc += 1
	else:
		fl = False
		s += a[i]
if s <= k and fo == False:
	cc += 1
print(cc)


s = input().split()
n = int(s[0])
k = int(s[1])
h = []
s = input().split()
for x in s:
	h.append(int(x))
h.sort()
hp = [0 for i in range(h[n - 1] + 2)]
for i in range(n):
	hp[h[i]] = i
for i in range(0, h[n - 1]):
	if hp[i + 1] == 0:
		hp[i + 1] = hp[i]
cnt = 0
now = 0
for i in range(h[n - 1] - 1, h[0] - 1, -1):
	if now + (n - hp[i] - 1) <= k:
		now += n - hp[i] - 1
	else:
		cnt += 1
		now = n - hp[i] - 1
if now > 0:
	cnt += 1
print(cnt)


(n, k) = map(int, input().split())
list1 = list(map(int, input().split()))
list1.sort()
height = list1[-1] - 1
sum1 = 0
num = 0
i = n - 1
ans = 0
while 1:
	if height == list1[0] - 1:
		if sum1 > 0:
			ans += 1
		break
	while i >= 0 and list1[i] > height:
		i -= 1
	num = n - i - 1
	if sum1 + num > k:
		ans += 1
		sum1 = num
	else:
		sum1 += num
	height -= 1
print(ans)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	heights = [0] * (max(a) + 2)
	for i in a:
		heights[0] += 1
		heights[i + 1] -= 1
	for i in range(1, len(heights)):
		heights[i] += heights[i - 1]
	heights.reverse()
	ans = 0
	now = 0
	for i in range(len(heights)):
		if heights[i] == n:
			if now:
				ans += 1
			break
		if now + heights[i] > k:
			ans += 1
			now = heights[i]
		else:
			now += heights[i]
	print(ans)
	return
main()


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
out = [0] * arr[-1]
h = 0
for i in range(n):
	while h < arr[i]:
		out[arr[-1] - h - 1] = n - i
		h += 1
tot = 0
ind = 0
l = len(out)
c = 0
for i in range(l - 1, -1, -1):
	if out[-1] == out[i]:
		c = i
out = out[:c]
l = len(out)
count = 0
while ind < l:
	while tot + out[ind] <= k:
		tot += out[ind]
		ind += 1
		if ind == l:
			break
	count += 1
	tot = 0
print(count)


MAX = 2 * 10 ** 5
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
count = [0] * (MAX + 1)
(maxH, minH) = (-float('inf'), float('inf'))
for h in a:
	count[h] += 1
	maxH = max(maxH, h)
	minH = min(minH, h)
ret = 0
i = maxH
while i > minH:
	cost = 0
	while i > minH and cost + count[i] <= k:
		cost += count[i]
		count[i - 1] += count[i]
		i -= 1
	ret += 1
print(ret)


from collections import Counter
(n, k) = list(map(int, input().split()))
h = list(map(int, input().split()))
cnt = Counter(h)
elems = 0
costs = []
hs = list(reversed(sorted(cnt.keys())))
cur_sum = 0
ans = 0
for i in range(len(hs) - 1):
	(v, c) = (hs[i], cnt[hs[i]])
	next_v = hs[i + 1]
	diff = v - next_v
	elems += c
	if cur_sum + elems > k:
		ans += 1
		cur_sum = 0
	if cur_sum + diff * elems <= k:
		cur_sum += diff * elems
	else:
		if cur_sum != 0:
			diff -= (k - cur_sum) // elems
			ans += 1
		per_cut = k // elems
		cuts = diff // per_cut
		cur_sum = diff % per_cut * elems
		ans += cuts
ans += cur_sum > 0
print(ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = sorted(arr, reverse=True)
total = 0
height = arr[0]
cost = 0
for i in range(n):
	while arr[i] < height:
		height -= 1
		if cost + i > k:
			total += 1
			cost = i
		else:
			cost += i
if cost > 0:
	total += 1
print(total)


from math import ceil
from collections import Counter

def f(n, k, a):
	cnt = [0] * (2 * 10 ** 5 + 1)
	for i in a:
		cnt[i] += 1
	for i in range(2 * 10 ** 5, 0, -1):
		cnt[i - 1] += cnt[i]
	cs = 0
	mn = min(a)
	ans = 0
	for i in range(2 * 10 ** 5, mn, -1):
		if cs + cnt[i] > k:
			ans += 1
			cs = 0
		cs += cnt[i]
		if cs > 0 and i == mn + 1:
			ans += 1
	return ans
(n, k) = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
print(f(n, k, l))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		(n, k) = ria()
		a = ria()
		z = [0] * 200005
		for i in a:
			z[i] += 1
		ma = max(a)
		mi = min(a)
		x = 0
		op = 0
		prevx = 0
		for i in range(ma, mi, -1):
			x += z[i]
			z[i - 1] += z[i]
			if x > k:
				x -= prevx
				op += 1
			prevx = x
		if x > 0:
			op += 1
		wi(op)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(mi, ma) = (min(a), max(a))
l = [0] * (ma + 1)
l[0] = n
for i in a:
	l[i] -= 1
for i in range(1, ma + 1):
	l[i] += l[i - 1]
sum = 0
ans = 0
for i in range(ma + 1):
	if l[i] < n:
		sum += l[i]
		if sum > k:
			sum = l[i]
			ans += 1
ans += 1 if sum else 0
print(ans)


MAX = 200000
(n, k) = map(int, input().split())
seq = [int(c) for c in input().split()]
cnt = [0] * (MAX + 2)
_min = min(seq)
for e in seq:
	cnt[e - _min] += 1
for i in range(MAX, 0, -1):
	cnt[i] = cnt[i + 1] + cnt[i]
ans = 0
cost = 0
for i in range(MAX, 0, -1):
	if cost + cnt[i] <= k:
		cost += cnt[i]
	else:
		cost = cnt[i]
		ans += 1
if cost > 0:
	ans += 1
print(ans)


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
height = [0 for i in range(2 * (10 ** 5 + 2))]
(m1, m2) = (max(arr), min(arr))
for i in arr:
	height[1] += 1
	height[i + 1] -= 1
for i in range(1, len(height)):
	height[i] += height[i - 1]
ans = 1
rem = 0
for i in range(m1, m2, -1):
	if rem + height[i] > k:
		ans += 1
		rem = height[i]
	else:
		rem += height[i]
if [arr[0]] * n == arr:
	print(0)
else:
	print(ans)


from sys import stdin, setrecursionlimit
import math
from collections import defaultdict, deque
setrecursionlimit(15000)

def get_cumulative(heights, mx):
	count = [0] * (mx + 1)
	for i in range(len(heights)):
		count[heights[i]] += 1
	for i in range(len(count) - 2, -1, -1):
		count[i] += count[i + 1]
	aux = dict()
	for i in range(len(count)):
		aux[i] = count[i]
	return aux

def get_upper_sum(count, heights):
	s = sum(heights)
	upper_sum = dict()
	h = max(heights)
	mn = min(heights)
	temp = 0
	upper_sum[h] = 0
	while True:
		if h == mn:
			break
		temp += count[h]
		upper_sum[h - 1] = temp
		h -= 1
	return upper_sum
(n, k) = list(map(int, stdin.readline().split()))
heights = list(map(int, stdin.readline().split()))
h = max(heights)
count = get_cumulative(heights, h)
upper_sum = get_upper_sum(count, heights)
mn = min(heights)
ans = 0
diff = 0
h = max(heights)
while True:
	if h < mn:
		break
	if upper_sum[h] - diff > k:
		ans += 1
		diff = upper_sum[h + 1]
		h += 1
		continue
	else:
		h -= 1
if upper_sum[h + 1] > diff:
	ans += 1
print(ans)


from collections import defaultdict
(n, k) = [int(el) for el in input().split()]
h = [int(el) for el in input().split()]
l = len(h)
d = defaultdict(int)
maxh = h[0]
minh = h[0]
for i in range(l):
	d[h[i]] += 1
	maxh = max(maxh, h[i])
	minh = min(minh, h[i])
if n == 1 or minh == maxh:
	print(0)
	raise SystemExit
s = list(d.keys())
s.sort()
cur1 = s.pop()
curval = 0
out = 1
while s != []:
	cur2 = s.pop()
	qnt = d[cur1]
	dif = cur1 - cur2
	val = dif * qnt
	if curval + val < k:
		curval += val
		d[cur2] += d[cur1]
		dele = d.pop(cur1)
		cur1 = cur2
		continue
	if curval + val == k:
		if s == []:
			print(out)
			raise SystemExit
		else:
			out += 1
			curval = 0
			d[cur2] += d[cur1]
			cur1 = cur2
			continue
	q = (k - curval) // qnt
	if q == 0:
		out += 1
		curval = 0
		s.append(cur2)
	else:
		curval = 0
		d[cur1 - q] = d[cur1 - q] + d[cur1]
		dele = d.pop(cur1)
		cur1 = cur1 - q
		out += 1
		s.append(cur2)
print(out)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
count = 0
temp = 0
f = [0] * (2 * 10 ** 5 + 1)
for i in arr:
	f[i] += 1
	if f[i] == n:
		print(0)
		exit(0)
temp = 0
m = 0
m = min(arr)
for i in range(2 * 10 ** 5 - 1, -1, -1):
	if f[i] == n:
		m = i
	f[i] += f[i + 1]
for i in range(2 * 10 ** 5, m, -1):
	temp += f[i]
	if temp > k:
		temp = f[i]
		count += 1
print(count + 1)


(a, b) = map(int, input().split())
n = list(map(int, input().split()))
x = 0
z = 100000
i = 0
while i < a:
	if n[i] > x:
		x = n[i]
	i += 1
k = [0] * x
i = 0
while i < a:
	k[n[i] - 1] += 1
	i += 1
i = x - 1
j = 1
z = 0
c = b
while i > -1:
	if k[i] + z == a:
		break
	if k[i] + z <= c:
		c -= k[i] + z
	else:
		c = b - k[i] - z
		j += 1
	z += k[i]
	i -= 1
if k[x - 1] == a:
	print(0)
else:
	print(j)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
a = [0] * (max(l) + 1)
for i in range(n):
	a[l[i]] += 1
arr = [0]
for i in range(len(a) - 1, min(l), -1):
	arr.append(a[i] + arr[-1])
arr.pop(0)
if len(arr) == 0:
	print(0)
else:
	ans = 0
	i = 0
	z = 0
	z += arr[i]
	while i < len(arr) - 1:
		if z + arr[i + 1] <= k:
			z += arr[i + 1]
			i += 1
		else:
			ans += 1
			i += 1
			z = arr[i]
	ans += 1
	print(ans)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
hs = {}
mx = 0
mn = 10 ** 6
for a in h:
	mx = max(mx, a)
	mn = min(mn, a)
	if a not in hs:
		hs[a] = 0
	hs[a] += 1
ans = 0
cur = 0
curcl = 0
for i in range(mx, mn, -1):
	if i not in hs:
		nc = 0
	else:
		nc = hs[i]
	if cur + nc + curcl <= k:
		cur += nc + curcl
		curcl += nc
	else:
		ans += 1
		curcl += nc
		cur = curcl
if cur > 0:
	ans += 1
print(ans)


import math, sys
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
sw = min(l)
s1 = max(l)
s = [0] * (s1 - sw)
d = dict()
for i in range(n):
	if l[i] not in d:
		d.update({l[i]: 1})
	else:
		d[l[i]] += 1
if len(s) == 0:
	print(0)
	sys.exit()
s[s1 - sw - 1] = d[s1]
for i in range(s1 - 1, sw, -1):
	if i not in d:
		tu = 0
	else:
		tu = d[i]
	s[i - sw - 1] = s[i - sw] + tu
s.reverse()
ans = 0
cur = 0
for i in range(len(s)):
	if cur + s[i] <= k:
		cur += s[i]
	else:
		cur = s[i]
		ans += 1
print(ans + 1)


import sys
lines = sys.stdin.readlines()
(n, k) = map(int, lines[0].strip().split(' '))
nums = list(map(int, lines[1].strip().split(' ')))
nums.sort(reverse=True)
cut = 0
tmpSum = 0
i = -1
while i < len(nums) - 1:
	if tmpSum - nums[i + 1] * (i + 1) > k:
		l = nums[i + 1]
		r = nums[i]
		while l < r - 1:
			m = l + (r - l) // 2
			if tmpSum - m * (i + 1) > k:
				l = m
			else:
				r = m
		cut += 1
		tmpSum = r * (i + 1)
		if (r - nums[i + 1]) * (i + 1) >= k:
			eachCut = k // (i + 1)
			addCut = (r - nums[i + 1]) // eachCut - 1
			tmpSum -= addCut * eachCut * (i + 1)
			cut += addCut
	else:
		tmpSum += nums[i + 1]
		i += 1
if tmpSum != nums[-1] * n:
	cut += 1
print(cut)


import sys
input = sys.stdin.readline

def HalfDead():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	l = []
	a.sort(reverse=True)
	for i in range(n - 1):
		for j in range(a[i] - a[i + 1]):
			l.append(i + 1)
	current = 0
	count = 0
	for i in range(len(l)):
		if current + l[i] > k:
			count += 1
			current = l[i]
		else:
			current += l[i]
	count += current != 0
	print(count)
HalfDead()


MAX_H = 2 * 10 ** 5

def main():
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	f = [0] * (MAX_H + 1)
	for i in h:
		f[i] += 1
	for i in range(MAX_H - 1, -1, -1):
		f[i] = f[i + 1] + f[i]
	(ans, cost, t, cur) = (0, 0, min(h), max(h))
	while t < cur:
		cost = 0
		while t < cur and cost + f[cur] <= k:
			cost += f[cur]
			cur -= 1
		ans += 1
	print(ans)
main()


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
min1 = min(h)
m = max(h) + 1 - min1
a = [0 for i in range(m + 5)]
for i in range(n):
	h[i] -= min1
	a[h[i]] += 1
for i in range(m - 2, -1, -1):
	a[i] += a[i + 1]
cnt = 0
cnt1 = 0
for i in range(m - 1, 0, -1):
	if cnt1 + a[i] > k:
		cnt1 = a[i]
		cnt += 1
	else:
		cnt1 += a[i]
if cnt1:
	cnt += 1
print(cnt)


(n, k) = map(int, input().split())
heights_list = list(reversed(sorted(list(map(int, input().split())))))
height = heights_list[0]
cost = 0
slices = 0
for i in range(n):
	while heights_list[i] < height:
		height -= 1
		if cost + i > k:
			slices += 1
			cost = i
		else:
			cost += i
if cost > 0:
	slices += 1
print(slices)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse=True)
levels = []
prev = h[0]
count = 1
for x in h[1:]:
	if x != prev:
		for _ in range(prev - x):
			levels.append(count)
		prev = x
	count += 1
if len(levels) == 0:
	print(0)
	exit(0)
s = 0
count = 1
for x in levels:
	s += x
	if s > k:
		count += 1
		s = x
print(count)


(n, k) = map(int, input().split())
hhh = list(map(int, input().split()))
h = [0] * 200005
hp = [0] * 200005
mx = 0
for i in hhh:
	h[i] += 1
	mx = max(mx, i)
res = n
for j in range(200003):
	hp[j] = res
	res -= h[j]
ans = 0
rr = 0
for t in range(mx, 0, -1):
	if hp[t] == n:
		break
	rr += hp[t]
	if rr > k:
		rr = hp[t]
		ans += 1
if rr:
	ans += 1
print(ans)


def ii():
	return int(input())

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

def li():
	return list(mi())
(n, k) = mi()
h = li()
m = max(h)
f = [0] * (m + 1)
for hi in h:
	f[hi] += 1
for i in range(m - 1, 0, -1):
	f[i] += f[i + 1]
ans = 0
i = m
while i > 0:
	if f[i] == n:
		break
	j = i
	cur = 0
	while j > 0:
		if cur + f[j] > k:
			break
		cur += f[j]
		j -= 1
	ans += 1
	i = j
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
minH = a[0]
maxH = a[-1]
cost = [0] * 200200
for i in range(minH + 1, maxH + 1):
	start = 0
	end = n - 1
	while end != start:
		g = (start + end + 1) // 2
		if i <= a[g]:
			end = g - 1
		else:
			start = g
	cost[i] = n - end - 1
cnt = 0
sumcost = 0
for i in range(minH + 1, maxH + 2):
	if sumcost <= k:
		sumcost += cost[i]
	else:
		cnt += 1
		sumcost = cost[i - 1] + cost[i]
if minH != maxH:
	cnt += 1
print(cnt)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
maxx = max(l)
minn = min(l)
deta = maxx - minn
li = [0] * deta
for i in range(n):
	v = maxx - l[i]
	if v < deta:
		li[v] += 1
s = 0
for i in range(deta):
	s += li[i]
	li[i] = s
c = s = 0
for i in range(deta):
	s = s + li[i]
	if s > k:
		c += 1
		s = li[i]
if s > 0:
	c += 1
print(c)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
min_ = min(A)
A = [A[i] - min_ for i in range(n)]
A.sort(reverse=True)
was = max(A)
i = 0
sum_ = 0
c = 0
ans = 0
last = was
while was >= 0:
	sumt = 0
	c1 = 0
	while i < len(A) and A[i] >= was:
		sumt += A[i] - was
		c1 += 1
		i += 1
	if sumt + sum_ + c + c1 > k:
		ans += 1
		sum_ = c + c1
		c += c1
		last = was
	else:
		sum_ += sumt + c + c1
		c += c1
	was -= 1
if last > 0:
	ans += 1
print(ans)


(n, k) = list(map(int, input().split()))
h = list(map(int, input().split()))
m = h[0]
m1 = h[0]
for i in h:
	m = max(m, i)
	m1 = min(m1, i)
if h == [m] * n:
	print(0)
else:
	a = [0] * m
	for i in h:
		a[i - 1] += 1
	b = [0] * m
	c = 0
	for i in range(m - 1, -1, -1):
		c += a[i]
		b[i] = c
	d = 0
	e = 0
	for i in range(m - 1, -1, -1):
		e += b[i]
		if i + 1 < m1:
			break
		if e > k or i + 1 == m1:
			e = b[i]
			d += 1
	print(d)


(n, k) = list(map(int, input().split()))
hs = list(map(int, input().split()))
mh = max(hs)
h = []
for i in range(0, mh + 1):
	h.append(0)
for hh in hs:
	h[hh] += 1
l = 0
good = 0
for i in range(mh, 0, -1):
	if h[i] == n:
		break
	if l + h[i] > k:
		good += 1
		l = h[i]
	else:
		l = l + h[i]
	h[i - 1] += h[i]
print(good + (1 if l > 0 else 0))


def main():
	maxn = 200005
	cnt = [0 for x in range(maxn)]
	(n, k) = str.split(input())
	n = int(n)
	k = int(k)
	a = str.split(input())
	Min = 100000005
	Max = 0
	for i in range(n):
		tmp = int(a[i])
		cnt[tmp] += 1
		if tmp < Min:
			Min = tmp
		if tmp > Max:
			Max = tmp
	Sum = 0
	ans = 0
	tot = 0
	while Max > Min:
		tot += cnt[Max]
		Sum += tot
		if Sum > k:
			Sum = tot
			ans += 1
		Max -= 1
	if Sum > 0:
		ans += 1
	print(ans)
main()


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def si():
	return input()

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(''.join([str(x) for x in a]) + '\n')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = 1
for _ in range(t):
	(n, k) = li()
	h = li()
	n = len(h)
	m = min(h)
	for i in range(n):
		h[i] -= m
	mx = max(h)
	arr = [0] * (mx + 1)
	h.sort()
	h.reverse()
	for i in range(n):
		arr[h[i]] += 1
	c = 0
	ans = 0
	cur = 0
	c = 0
	for i in range(mx, 0, -1):
		c = arr[i] + c
		cur += c
		if cur > k:
			ans += 1
			cur = c
	if cur > 0:
		ans += 1
	print(ans)


MAXN = int(200000.0 + 5)
(n, k) = map(int, input().split())
h = list(map(int, input().split()))
count = [0] * MAXN
for i in h:
	count[i] += 1
su = 0
pos = MAXN - 1
c = 0
highest = max(h)
lowest = min(h)
res = 0
while True:
	x = su - c * (pos - 1)
	if x > k:
		su = pos * c
		res += 1
		highest = pos
	pos -= 1
	if pos == lowest:
		break
	c += count[pos]
	su += count[pos] * pos
if highest != lowest:
	res += 1
print(res)


(n, m) = map(int, input().split())
b = [0 for i in range(200002)]
c = [0 for i in range(200002)]
hmax = 0
hmin = 200005
a = list(map(int, input().split()))
for i in range(n):
	hmax = max(hmax, a[i])
	hmin = min(hmin, a[i])
	c[a[i]] += 1
b[200000] = c[200000]
for i in range(200000 - 1, -1, -1):
	b[i] = b[i + 1] + c[i]
cur = hmax
ans = 0
while cur > hmin:
	cnt = 0
	while cnt <= m:
		if cnt + b[cur] <= m and cur > hmin:
			cnt += b[cur]
			cur -= 1
		else:
			ans += 1
			cnt = 0
			break
	if cur == hmin:
		break
print(ans)


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def solve():
	(n, k) = mi()
	a = li()
	freq = [0] * 200001
	for i in a:
		freq[i] += 1
	(ans, s) = (0, 0)
	for i in range(200000, -1, -1):
		if freq[i] == n:
			if s > 0:
				ans += 1
			break
		s += freq[i]
		if s > k:
			ans += 1
			s = freq[i]
		freq[i - 1] += freq[i]
	print(ans)
solve()


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
m = max(h)
A = [0] * (m + 1)
for i in range(n):
	A[h[i]] += 1
min_h = min(h)
ans = 0
c = 0
s = 0
pos = m
while pos > min_h:
	c += A[pos]
	s += A[pos] * pos
	pos -= 1
	x = s - c * pos
	if x > k:
		ans += 1
		s = c * (pos + 1)
if s - c * pos > 0:
	ans += 1
print(ans)


(n, k) = list(map(int, input().split()))
h = list(map(int, input().split()))
(mmin, mmax) = (h[0], h[0])
d = [0] * 200001
for i in range(n):
	cur = h[i]
	d[cur] += 1
	if h[i] < mmin:
		mmin = h[i]
	if h[i] > mmax:
		mmax = h[i]
if n == 1 or mmax == mmin:
	print(0)
else:
	ans = 0
	i = 200000
	cur = k
	while i > mmin:
		if d[i] <= cur:
			d[i - 1] += d[i]
			cur -= d[i]
			i -= 1
		else:
			cur = k
			ans += 1
	print(ans + 1)


(n, k) = map(int, input().split())
(*l,) = map(int, input().split())
(T, t) = (max(l), min(l))
d = [0] * (T - t)
for i in l:
	if i != t:
		d[T - i] += 1
a = s = 0
for i in range(len(d)):
	s += d[i]
	if i < len(d) - 1:
		d[i + 1] += d[i]
	if s > k:
		s = d[i]
		a += 1
print(a + 1 if d else a)


(n, k) = map(int, input().split())
h = list(map(int, input().split()))
flag = True
for i in range(n - 1):
	if h[i] != h[i + 1]:
		flag = False
		break
if n == 1 or flag:
	print(0)
else:
	val = [0] * 200005
	for i in range(n):
		val[h[i]] += 1
	i = 200004
	count = 0
	while i > 0 and val[i] < n:
		cost = 0
		while i > 0 and val[i] + cost <= k:
			cost += val[i]
			val[i - 1] += val[i]
			val[i] = 0
			i -= 1
		count += 1
		if val[i] == n:
			break
	print(count)


(n, k) = map(int, input().split())
h = [int(x) for x in input().split()]
h.sort()
m = h[0]
h = [x - m for x in h]
t = 1
i = 0
res = 0
tmp = 0
while i != n:
	if h[i] >= t:
		if tmp + n - i > k:
			res += 1
			tmp = n - i
		else:
			tmp += n - i
		t += 1
	else:
		i += 1
print(res + (1 if tmp > 0 else 0))