One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers.

If there are exactly $K$ distinct values in the array, then we need $k = \lceil \log_{2} K \rceil$ bits to store each value. It then takes $nk$ bits to store the whole file.

To reduce the memory consumption we need to apply some compression. One common way is to reduce the number of possible intensity values. We choose two integers $l \le r$, and after that all intensity values are changed in the following way: if the intensity value is within the range $[l;r]$, we don't change it. If it is less than $l$, we change it to $l$; if it is greater than $r$, we change it to $r$. You can see that we lose some low and some high intensities.

Your task is to apply this compression in such a way that the file fits onto a disk of size $I$ bytes, and the number of changed elements in the array is minimal possible.

We remind you that $1$ byte contains $8$ bits.

$k = \lceil log_{2} K \rceil$ is the smallest integer such that $K \le 2^{k}$. In particular, if $K = 1$, then $k = 0$.


-----Input-----

The first line contains two integers $n$ and $I$ ($1 \le n \le 4 \cdot 10^{5}$, $1 \le I \le 10^{8}$) — the length of the array and the size of the disk in bytes, respectively.

The next line contains $n$ integers $a_{i}$ ($0 \le a_{i} \le 10^{9}$) — the array denoting the sound file.


-----Output-----

Print a single integer — the minimal possible number of changed elements.


-----Examples-----
Input
6 1
2 1 2 3 4 3

Output
2

Input
6 2
2 1 2 3 4 3

Output
0

Input
6 1
1 1 2 2 3 3

Output
2



-----Note-----

In the first example we can choose $l=2, r=3$. The array becomes 2 2 2 3 3 3, the number of distinct elements is $K=2$, and the sound file fits onto the disk. Only two values are changed.

In the second example the disk is larger, so the initial file fits it and no changes are required.

In the third example we have to change both 1s or both 3s.

Difficulty: MEDIUM_HARD
Tags: Sorting

Amortized analysis
Skill types: Sorting

Amortized analysis

Starter code:

Solutions:
from collections import *
from math import *
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = Counter(a)
a.sort()
val = [0 for i in range(400005)]
a = list(set(a))
a.sort()
n1 = len(a)
val[0] = d[a[0]]
for i in range(1, n1):
	val[i] = val[i - 1] + d[a[i]]
m = n1
for m in range(n1, 0, -1):
	s = ceil(log2(m))
	if s * n <= 8 * k:
		break
m1 = val[m - 1]
for i in range(m, n1):
	m1 = max(m1, val[i] - val[i - m])
print(n - m1)


from math import log2, ceil
(n, k) = map(int, input().split())
k *= 8
a = sorted(list(map(int, input().split())))
(q1, dif) = (0, 1)
ans = float('inf')
for q in range(n):
	while n * ceil(log2(dif)) <= k and q1 < n:
		if q1 == n - 1 or a[q1] != a[q1 + 1]:
			dif += 1
		q1 += 1
	ans = min(ans, q + n - q1)
	if q != n - 1 and a[q] != a[q + 1]:
		dif -= 1
print(ans)


def naiveSolve(n):
	return

def main():
	(n, I) = readIntArr()
	a = readIntArr()
	k = 8 * I // n
	K = pow(2, k)
	a.sort()
	b = [0] * n
	v = 0
	for i in range(n):
		if i - 1 >= 0 and a[i] > a[i - 1]:
			v += 1
		b[i] = v
	a = b
	ans = inf
	r = -1
	for l in range(n):
		lower = a[l]
		upper = K + lower - 1
		while r + 1 < n and a[r + 1] <= upper:
			r += 1
		ans = min(ans, l + n - 1 - r)
	print(ans)
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

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

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(l, r):
	print('? {} {}'.format(l, r))
	sys.stdout.flush()
	return int(input())

def answerInteractive(x):
	print('! {}'.format(x))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
from math import gcd, floor, ceil
for _abc in range(1):
	main()


import os
import sys
from io import BytesIO, IOBase
import math
from collections import Counter

def main():
	(n, I) = map(int, input().split())
	a = list(map(int, input().split()))
	k = pow(2, 8 * I // n)
	b = [0]
	a.sort()
	for i in range(1, n):
		if a[i] != a[i - 1]:
			b.append(i)
	if k >= len(b):
		print(0)
	else:
		m = 0
		for i in range(len(b) - k):
			m = max(m, b[i + k] - b[i])
		print(n - m)
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()


from collections import Counter, deque
from math import log2
(n, I) = map(int, input().split())
debug = False
mp3 = list(map(int, input().split()))
assert n == len(mp3)
if n == 0:
	print(0)
	exit(0)
mp3 = sorted(mp3)
bts_avail = I * 8 // n
if debug:
	diff = mp3[-1] - mp3[0]
	bits = 0
	pwr2 = 1
	while pwr2 < diff:
		bits += 1
		pwr2 <<= 1
	print('diff: {}'.format(diff))
	print('pwr2: {}'.format(pwr2))
	print('bits: {}'.format(bits))
	print('bts_avail: {}'.format(bts_avail))
	print('rng: {}'.format(rng))
max_range = 0
window = deque()
wrng = 0
for (Ampl, freq) in Counter(mp3).items():
	window.append(freq)
	wrng += freq
	if wrng > max_range:
		max_range = wrng
	if log2(len(window)) == bts_avail:
		wrng -= window.popleft()
print(n - max_range)


import sys
input = sys.stdin.readline
(n, I) = map(int, input().split())
a = list(map(int, input().split()))
k = I * 8 // n
K = 2 ** k
d = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = 0
	d[a[i]] += 1
keys = list(d.keys())
keys.sort()
num = 0
maxNum = 0
for i in range(len(keys)):
	num += d[keys[i]]
	if i >= K:
		num -= d[keys[i - K]]
	maxNum = max(maxNum, num)
res = n - maxNum
print(res)


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')
import math
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = set()
d = dict()
dis = 0
for i in range(n):
	if l[i] not in s:
		dis += 1
		s.add(l[i])
		d.update({l[i]: 1})
	else:
		d[l[i]] += 1
dis = math.ceil(math.log(dis, 2)) * n
if dis <= 8 * k:
	print(0)
else:
	u = list(s)
	u.sort()
	c = [0] * (len(u) + 1)
	m = 0
	c[0] = 0
	c[1] = d[u[0]]
	for i in range(2, len(u) + 1):
		c[i] = c[i - 1] + d[u[i - 1]]
	k = 2 ** (8 * k // n)
	for i in range(len(c) - 1, k - 1, -1):
		m = max(c[i] - c[i - k], m)
	print(n - m)


import sys
import os
from io import BytesIO, IOBase

def cel(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return defaultdict(int)

def ddl():
	return defaultdict(list)

def ddd():
	return defaultdict(defaultdict(int))
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 defaultdict
from math import gcd, log2, ceil
for _ in range(1):
	(n, its) = mi()
	a = li()
	s = sorted(set(a))
	s = list(s)
	if n * ceil(log2(len(s))) <= 8 * its:
		print(0)
		continue
	d = dd()
	for i in range(n):
		d[a[i]] += 1
	k = 2 ** (8 * its // n)
	prfx = [0 for i in range(len(s) + 1)]
	for i in range(1, len(prfx)):
		prfx[i] = prfx[i - 1] + d[s[i - 1]]
	mx = 0
	for i in range(len(prfx) - 1, k - 1, -1):
		mx = max(prfx[i] - prfx[i - k], mx)
	print(n - mx)


from collections import defaultdict, Counter
from math import floor
(n, I) = map(int, input().split())
List = [int(x) for x in input().split()]
k = pow(2, min(20, floor(I * 8 / n)))
List.sort()
arr = [[List[0], 1]]
for i in range(1, n):
	if List[i] == arr[-1][0]:
		arr[-1][1] += 1
	else:
		arr.append([List[i], 1])
arr.sort()
prefix = [0]
for i in arr:
	prefix.append(prefix[-1] + i[1])
Max = 0
if k >= len(prefix):
	print(0)
	exit()
for i in range(k, len(prefix)):
	Max = max(prefix[i] - prefix[i - k], Max)
print(n - Max)


from collections import defaultdict as dd
(n, l) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
distinct = 2 ** (l * 8 // n)
st = len(set(arr))
if st <= distinct:
	print(0)
else:
	d = dd(int)
	for i in range(n):
		d[arr[i]] += 1
	l1 = []
	for i in sorted(d.keys()):
		l1.append(d[i])
	mx = 0
	s1 = sm = sum(l1[:distinct])
	for i in range(distinct, len(l1)):
		sm += l1[i] - l1[i - distinct]
		s1 = max(s1, sm)
	print(n - s1)


import math
(n, I) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
I *= 8
k = 1 << I // n
dp = [1]
for i in range(1, n):
	if a[i] == a[i - 1]:
		dp[-1] += 1
	else:
		dp.append(1)
if k >= len(dp):
	print(0)
else:
	ans = sum(dp[:k])
	ret = ans
	for i in range(k, len(dp)):
		ans += dp[i] - dp[i - k]
		ret = max(ret, ans)
	print(n - ret)


from itertools import accumulate
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
L = []
prev = -1
for a in A:
	if a == prev:
		L[-1] += 1
	else:
		L.append(1)
		prev = a
max_types = int(2 ** (8 * K // N))
all_types = len(L)
del_types = all_types - max_types
if del_types <= 0:
	ans = 0
else:
	ans = float('inf')
	sum_L = N
	L_acc = [0] + list(accumulate(L))
	for i in range(len(L) - max_types):
		s = L_acc[i + max_types] - L_acc[i]
		ans = min(ans, sum_L - s)
print(ans)


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import sys
import string
import random
from typing import List
sys.setrecursionlimit(99999)
(n, l) = map(int, input().split())
arr = list(map(int, input().split()))
k = 8 * l // n
sa = set(arr)
mk = len(sa).bit_length()
if k >= mk:
	print(0)
else:
	p = 2 ** k
	cs = collections.Counter(arr)
	ks = list(cs.keys())
	ks.sort()
	ans = 0
	temp = 0
	i = 0
	for j in range(len(ks)):
		temp += cs[ks[j]]
		while j - i >= p:
			temp -= cs[ks[i]]
			i += 1
		ans = max(ans, temp)
	print(n - ans)


(n, size) = map(int, input().split())
a = list(map(int, input().split()))
limit = 2 ** (size * 8 // n)
a.sort()
l = [0]
for i in range(1, n):
	if a[i - 1] != a[i]:
		l.append(i)
if len(l) <= limit:
	print(0)
else:
	print(n - max((l[i + limit] - l[i] for i in range(len(l) - limit))))


from itertools import groupby

def mp3(n, I, a):
	k = int(I * 8 / n)
	d = 1 << k
	c = [len(list(group)) for (key, group) in groupby(sorted(a))]
	chgs = sum(c[d:])
	ans = chgs
	for i in range(0, len(c) - d):
		chgs += c[i]
		chgs -= c[i + d]
		ans = min(ans, chgs)
	return ans

def __starting_point():
	(nn, II) = list(map(int, input().split()))
	aa = list(map(int, input().split()))
	print(mp3(nn, II, aa))
__starting_point()


from math import ceil, log2
(n, I) = map(int, input().split())
data = list(map(int, input().split()))
data.sort()
needK = I * 8 // n
distinct = len(set(data))
if needK >= ceil(log2(distinct)):
	print(0)
	exit()
pref = [0] * distinct
cur = data[0]
ind = 0
for val in data:
	if val != cur:
		ind += 1
		cur = val
	pref[ind] += 1
waste = distinct - 2 ** needK
bad = 0
p = waste
for i in range(p):
	bad += pref[i]
ans = bad
for i in range(p - 1, -1, -1):
	bad -= pref[i]
	bad += pref[distinct - 1 - (p - 1 - i)]
	ans = min(ans, bad)
print(ans)


R = lambda : map(int, input().split())
(n, I) = R()
a = sorted(R())
b = [0] + [i + 1 for i in range(n - 1) if a[i] < a[i + 1]] + [n]
print(n - max((y - x for (x, y) in zip(b, b[1 << 8 * I // n:])), default=n))


from collections import Counter
(n, I) = map(int, input().split())
a = list(map(int, input().split()))
c = Counter(a)
sorted_keys = sorted(c.keys())
acc_counts = [0] * (len(c) + 1)
sorted_keys_len = len(sorted_keys)
for i in range(1, sorted_keys_len + 1):
	acc_counts[i] = acc_counts[i - 1] + c[sorted_keys[i - 1]]
variations = 2 ** (8 * I // n)
if variations >= sorted_keys_len:
	print(0)
else:
	min_v = float('inf')
	for i in range(1, sorted_keys_len + 1 - variations):
		(x, y) = (i, i + variations)
		v = acc_counts[y] - acc_counts[x]
		min_v = min(min_v, n - v)
	print(min_v)


from math import log
(n, s) = map(int, input().split())
lis = sorted(map(int, input().split()))
lim = 2 ** (s * 8 // n)
if lim >= len(set(lis)):
	print(0)
else:
	pre = [0] * (n + 1)
	pre[0] = 1
	ans = 100000000000
	for i in range(1, n):
		if lis[i] != lis[i - 1]:
			pre[i] = pre[i - 1] + 1
		else:
			pre[i] = pre[i - 1]
	for i in range(n):
		l = i
		r = n - 1
		if pre[i] == pre[i - 1]:
			continue
		while l <= r:
			mid = l + (r - l) // 2
			if pre[mid] - pre[i - 1] <= lim:
				l = mid + 1
			else:
				r = mid - 1
		ans = min(ans, n - (l - i))
	print(ans)


from collections import Counter
(nn, i) = map(int, input().strip().split(' '))
a = [int(x) for x in input().strip().split(' ')]
ad = dict(Counter(a))
a = sorted(ad)
k = 8 * i // nn
storage = 2 ** min(20, k)
if len(Counter(a).keys()) <= storage:
	print(0)
else:
	n = len(a)
	sm = 0
	i = 0
	j = storage
	while i < j:
		sm = sm + ad[a[i]]
		i = i + 1
	msum = sm
	i = 0
	while j < n:
		sm = sm - ad[a[i]] + ad[a[j]]
		i = i + 1
		j = j + 1
		msum = max(sm, msum)
	print(nn - msum)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))
import math
from bisect import bisect_right
(n, b) = getList()
numms = getList()
numms.sort()
spl = 0
tmp = numms[0]
nums = []
for nu in numms:
	if nu == tmp:
		nums.append(spl)
	else:
		spl += 1
		nums.append(spl)
		tmp = nu
haba = 2 ** (8 * b // n)
ans = 0
for (i, num) in enumerate(nums):
	ins = num + haba - 1
	idx = bisect_right(nums, ins)
	rep = idx - i
	if rep > ans:
		ans = rep
print(n - ans)


(n, i) = map(int, input().split())
aa = list(map(int, input().split()))
bitsPerSample = i * 8 // n
r = 2 ** bitsPerSample
aa.sort()
prev = -1
bb = []
for (i, a) in enumerate(aa):
	if a != prev:
		bb.append(i)
		prev = a
if len(bb) <= r:
	maxOk = n
else:
	maxOk = max([bb[i + r] - bb[i] for i in range(len(bb) - r)])
print(n - maxOk)


import sys, math
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
se = set(l)
d = dict()
if 8 * k >= n * math.ceil(math.log(len(se), 2)):
	ans = 0
	print(ans)
	sys.exit()
r = pow(2, 8 * k // n)
for i in range(len(l)):
	if l[i] not in d:
		d.update({l[i]: 1})
	else:
		d[l[i]] += 1
freq = []
for i in sorted(d):
	freq.append(d[i])
s = 0
e = len(freq) - 1
k = len(se)
for i in range(1, len(freq)):
	freq[i] += freq[i - 1]
ans = 999999999999999999
freq = [0] + freq
for i in range(k - r + 1):
	rt = freq[i] + freq[-1] - freq[len(freq) - 1 + i - k + r]
	ans = min(ans, rt)
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
m *= 8
m = m // n
m = 2 ** m
d = {}
for i in a:
	try:
		d[i] += 1
	except:
		d[i] = 1
a.sort()
val = [0]
mx = 0
for i in range(1, n):
	if a[i - 1] != a[i]:
		val.append(i)
diff = len(val) - m
if len(val) <= m:
	print(0)
else:
	for i in range(diff):
		mx = max(val[i + m] - val[i], mx)
	print(n - mx)


from collections import Counter
(N, I) = map(int, input().split())
counter = Counter(list(map(int, input().split())))
a = [v for (k, v) in sorted(counter.items())]
bits = I * 8 // N
if bits >= 30 or 2 ** bits >= len(a):
	print(0)
	exit()
sound_range = 2 ** bits
r = 0
acc = 0
for i in range(sound_range):
	acc += a[r]
	r += 1
ans = acc
for (lv, rv) in zip(a, a[r:]):
	acc += rv - lv
	if acc > ans:
		ans = acc
print(N - ans)


import collections
(n, I) = list(map(int, input().split()))
L = sorted(map(int, input().split()))
bits_per_elem = I * 8 // n
K = 2 ** min(bits_per_elem, 32)
freq = list(collections.Counter(L).values())
if K >= len(freq):
	print(0)
	exit()
for i in range(1, len(freq)):
	freq[i] += freq[i - 1]
res = n
for i in range(len(freq) - K):
	res = min(res, freq[i] + freq[-1] - freq[i + K])
print(res)


(n, I) = [int(w) for w in input().split()]
a = [int(w) for w in input().split()]
k = 8 * I // n
K = 2 ** k
a.sort()
b = [0]
for i in range(1, n):
	if a[i - 1] != a[i]:
		b.append(i)
if len(b) <= K:
	print(0)
else:
	print(n - max((b[i + K] - b[i] for i in range(len(b) - K))))


import os
import sys
import string
import math

def main(n, I, data):
	max_k = 8 * I // n
	max_K = 2 ** max_k
	counts = {}
	for num in data:
		if num not in counts:
			counts[num] = 0
		counts[num] += 1
	values = sorted(counts.keys())
	counts = [counts[key] for key in values]
	if len(counts) <= max_K:
		return 0
	s = [0]
	for i in range(len(counts)):
		s.append(s[-1] + counts[i])
	total = s[-1]
	ans = total
	for i in range(len(counts) - max_K + 1):
		ans = min(ans, total - s[i + max_K] + s[i])
	return ans

def parse():
	(n, I) = input().split(' ')
	(n, I) = (int(n), int(I))
	data = [int(i) for i in input().split(' ')]
	return (n, I, data)

def output(ans):
	print(ans)
output(main(*parse()))


import sys
input = sys.stdin.readline
from bisect import *

def ceil_log2(K):
	for i in range(30):
		if 2 ** i >= K:
			return i
(n, I) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
sa = list(set(a))
for K in range(n, -1, -1):
	if n * ceil_log2(K) <= 8 * I:
		max_K = K
		break
if len(sa) < max_K:
	print(0)
	exit()
ans = n
for i in range(len(sa) - max_K + 1):
	left_change = bisect_left(a, sa[i])
	right_change = n - bisect_right(a, sa[i + max_K - 1])
	ans = min(ans, left_change + right_change)
print(ans)


from sys import stdin, stdout
(N, I) = [int(x) for x in stdin.readline().split()]
arr = [int(x) for x in stdin.readline().split()]
arr.sort()
bits = I * 8
bound = bits // N
if bound >= 50:
	bound = 50
max_K = 2 ** bound
freq = []
f = 0
last = arr[0]
for num in arr:
	if num == last:
		f += 1
	else:
		freq.append(f)
		f = 1
	last = num
freq.append(f)
prefix = [0] * len(freq)
s = 0
i = 0
for f in freq:
	s += f
	prefix[i] = s
	i += 1
res = N + 1
for i in range(max_K - 1, len(freq)):
	if i == max_K - 1:
		res = min(res, N - prefix[i])
	else:
		res = min(res, N - prefix[i] + prefix[i - max_K])
if res == N + 1:
	print(0)
else:
	print(res)


import math
(n, I) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
vals = 2 ** (I * 8 // n)
K = len(a)
if K > vals:
	d = {}
	for i in a:
		d[i] = d.get(i, 0) + 1
	d = list(d.items())
	s = sum([val for (key, val) in d[:vals]])
	maxs = s
	for i in range(vals, len(d)):
		s = s - d[i - vals][1] + d[i][1]
		maxs = max(maxs, s)
	print(n - maxs)
else:
	print(0)


(n, i) = list(map(int, input().split()))
k = 2 ** (8 * i // n) if 8 * i // n < 20 else n
a = [int(x) for x in input().split()]
a.sort()
freq = [1]
for i in range(1, len(a)):
	if a[i - 1] == a[i]:
		freq[-1] += 1
	else:
		freq.append(1)
window = sum(freq[:k])
ans = window
for i in range(k, len(freq)):
	window += freq[i]
	window -= freq[i - k]
	ans = max(ans, window)
print(n - ans)


from math import log, floor
(n, I) = map(int, input().split())
a = [int(s) for s in input().split()]
b = []
a.sort()
b.append([-1, 0])
for i in range(0, n):
	if a[i] == b[-1][0]:
		b[-1][1] += 1
	else:
		b.append([a[i], b[-1][1] + 1])
maxk = I * 8 // n
maxK = 1 << maxk
ans = n
if len(b) - 1 < maxK:
	ans = 0
else:
	for i in range(len(b) - maxK):
		chg = n - (b[i + maxK][1] - b[i][1])
		if chg < ans:
			ans = chg
print(ans)


from sys import stdin
(n, i) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
i *= 8
K = 2 ** (i // n)
a.sort()
b = []
for i in a:
	if not b or b[-1][0] != i:
		b.append([i, 0])
	b[-1][1] += 1
current = 0
for i in range(K, len(b)):
	current += b[i][1]
ans = current
for r in range(K, len(b)):
	current += b[r - K][1]
	current -= b[r][1]
	ans = min(ans, current)
print(ans)


(n, I) = list(map(int, input().split()))
l = list(map(int, input().split()))
k = 2 ** (I * 8 // n)
dd = {}
for x in l:
	if x in dd:
		dd[x] += 1
	else:
		dd[x] = 1
l = [dd[x] for x in sorted(dd)]
n = len(l)
if k >= n:
	print(0)
else:
	ss = sum(l[:k])
	mxm = ss
	for i in range(1, n - k + 1):
		ss += l[i + k - 1] - l[i - 1]
		if mxm < ss:
			mxm = ss
	print(sum(l) - mxm)


def max_sub(list, k):
	n = len(list)
	(i, sum, m) = (0, 0, 0)
	while i < k:
		sum += list[i]
		i += 1
	m = max(sum, m)
	rem = 0
	while i < n:
		sum -= list[rem]
		rem += 1
		sum += list[i]
		i += 1
		m = max(sum, m)
	return m
import math
(n, bytes) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
temp = []
count = 1
for i in range(1, n):
	if l[i] == l[i - 1]:
		count += 1
	else:
		temp.append(count)
		count = 1
temp.append(count)
m = len(temp)
if n * math.ceil(math.log(m, 2)) <= bytes * 8:
	print(0)
else:
	max_k = m
	while math.ceil(math.log(max_k, 2)) != bytes * 8 // n:
		max_k -= 1
	y = max_sub(temp, max_k)
	print(sum(temp) - y)


import math
(n, I) = [int(x) for x in input().split()]
lis = [int(x) for x in input().split()]
dic = dict()
for i in lis:
	if i in dic:
		dic[i] += 1
	else:
		dic[i] = 1
disLis = sorted(dic)
nowK = len(disLis)
if math.log2(nowK) > I * 8 // n:
	maxK = 2 ** (I * 8 // n)
	needMin = nowK - maxK
	minChange = 0
	for i in range(needMin):
		minChange += dic[disLis[i]]
	befChange = minChange
	for i in range(1, needMin + 1):
		befChange = befChange - dic[disLis[needMin - i]] + dic[disLis[-i]]
		if befChange < minChange:
			minChange = befChange
	print(minChange)
else:
	print(0)


def main():
	(n, k) = map(int, input().split())
	k *= 8
	a = sorted(list(map(int, input().split())))
	a1 = [a[0]]
	for i in range(1, n):
		if a[i] != a[i - 1]:
			a1.append(a[i])
	count = k // n
	ans = pow(2, count)
	b = {}
	for i in range(len(a1)):
		b[a1[i]] = i
	c = [0 for i in range(n)]
	for i in range(n):
		c[b[a[i]]] += 1
	pr = [0]
	for i in range(len(a1)):
		pr.append(c[i] + pr[-1])
	min1 = 10 ** 9
	for i in range(len(a1)):
		min1 = min(n - (pr[min(i + ans, len(a1))] - pr[i]), min1)
	print(min1)
main()


import math
import sys
input = sys.stdin.readline
(n, I) = list(map(int, input().split()))
A = list(map(int, input().split()))
k = math.floor(I * 8 / n)
K = 2 ** min(k, 20)
s = sorted(set(A))
dis = len(s)
count = {}
for i in range(n):
	if A[i] not in count:
		count[A[i]] = 1
	else:
		count[A[i]] += 1
diff = max(dis - K, 0)
ct = 0
for i in range(diff):
	ct += count[s[i]]
ans = ct
for i in range(diff - 1, -1, -1):
	ct -= count[s[i]]
	ct += count[s[i + K]]
	ans = min(ans, ct)
print(ans)


(n, I) = map(int, input().split())
I *= 8
I //= n
arr = list(map(int, input().split()))
arr.sort()
smen = [0]
typs = 1
for i in range(1, n):
	if arr[i] != arr[i - 1]:
		typs += 1
		smen.append(i)
smen.append(n)
deg = 1
lg = 0
while deg < typs:
	lg += 1
	deg *= 2
if lg == 0 or I >= lg:
	print(0)
else:
	degi = 2 ** I
	mon = typs - degi
	ans = 400001
	for x in range(mon + 1):
		now = smen[x] + n - smen[typs - mon + x]
		if now < ans:
			ans = now
	print(ans)


import math
import sys
from collections import defaultdict, Counter, deque, OrderedDict
import bisect
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]
from itertools import accumulate, groupby
(n, I) = ilele()
A = alele()
tot = I * 8
C = Counter(A)
E = list(C.keys())
E.sort()
pre = [0]
for i in E:
	pre.append(C[i] + pre[-1])
i = 0
j = 0
c = len(E)
while j < c:
	z = n * math.ceil(math.log(j + 1, 2))
	if z <= tot:
		j += 1
	else:
		break
Ans = 1000000000.0
if j == c:
	print(0)
else:
	while j <= c:
		Ans = min(Ans, n - pre[j] + pre[i])
		i += 1
		j += 1
	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, x) = mi()
	a = li()
	m = dd(int)
	x *= 8
	n1 = n
	for i in a:
		m[i] += 1
	a = list(set(a))
	a.sort()
	n = len(a)
	suff = [0] * n
	pre = [0] * n
	for i in range(n - 2, -1, -1):
		suff[i] = suff[i + 1] + m[a[i + 1]]
	for i in range(1, n):
		pre[i] = pre[i - 1] + m[a[i - 1]]
	ans = n1
	l = 0
	s = 0
	x //= n1
	k = 1
	for i in range(x):
		k *= 2
		if k > n:
			break
	for i in range(n - k + 1):
		ans = min(ans, pre[i] + suff[i + k - 1])
	if ans == n1:
		ans = 0
	print(ans)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
solve()


import math
(n, I) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
last = -1
amount = []
for i in range(0, n):
	if a[i] != last:
		last = a[i]
		amount.append(1)
	else:
		amount[-1] += 1
k = math.ceil(math.log(len(amount), 2))
best = 0
now = 0
if n * k <= I * 8:
	print(0)
else:
	K = 2 ** (8 * I // n)
	for i in range(0, len(amount)):
		now += amount[i]
		if i > K - 1:
			now -= amount[i - K]
		if now > best:
			best = now
	print(n - best)


(n, p) = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
t = 2 ** (8 * p // n)
last = None
y = []
for c in x:
	if last is None or last != c:
		last = c
		y.append(1)
	else:
		y[-1] += 1
best = 0
now = 0
le = len(y)
for i in range(le):
	now += y[i]
	if i >= t:
		now -= y[i - t]
	best = max(best, now)
print(n - best)


import sys
in_file = sys.stdin
(n, I) = map(int, in_file.readline().strip().split())
A = list(map(int, in_file.readline().strip().split()))
max_k = I * 8 // n
m = 2 ** max_k
A.sort()
t = A[0]
B = [0]
for a in A:
	if a == t:
		B[-1] += 1
	else:
		t = a
		B.append(1)
res = sum(B[:m])
t = res
for i in range(m, len(B)):
	t += B[i] - B[i - m]
	if t > res:
		res = t
sys.stdout.write(str(n - res))
sys.stdout.flush()


from itertools import groupby as gb
(N, I) = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
l = []
G = gb(A)
for (k, v) in G:
	l.append(len(list(v)))
k = 100
while True:
	if N * k > 8 * I:
		k -= 1
	else:
		break
K = 2 ** k
NN = len(l)
if NN <= K:
	print(0)
	exit()
sm = sum(l[:K])
mx = sm
for i in range(K, NN):
	sm += l[i] - l[i - K]
	mx = max(mx, sm)
print(sum(l) - mx)


line = input()
tmp = line.split(' ')
(n, k) = (int(tmp[0]), int(tmp[1]))
line1 = input()
lst = [int(i) for i in line1.split(' ')]
lst.sort()
(last, dis, ans, cnt) = (-1, 0, n, 0)
left = 0
if k * 8 // n > n:
	print('0')
else:
	mx = 2 ** (k * 8 // n)
	for (idx, num) in enumerate(lst):
		cnt += 1
		if num != last:
			dis += 1
			if dis > mx:
				new_left = left
				while lst[new_left] == lst[left]:
					new_left += 1
					cnt -= 1
				left = new_left
				dis -= 1
		ans = min(ans, n - cnt)
		last = num
	print(ans)


(n, I) = map(int, input().split())
a = sorted(list(map(int, input().split())))
cur = 0
b = [0]
for i in range(1, n):
	if a[i] != a[i - 1]:
		cur += 1
	b.append(cur)
r = 1
ans = int(1e+18)
for l in range(len(b)):
	ma = b[l] + 2 ** min(I * 8 // n, 30) - 1
	while r < n and b[r] <= ma:
		r += 1
	ans = min(ans, l + (n - r))
print(ans)


from math import *
(n, I) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a = sorted(a)
s = len(set(a))
req = 0
for i in range(1, s + 1):
	lg = int(ceil(log2(i)))
	lg *= n
	if lg <= I * 8:
		req = i
	else:
		break
s = []
i = 0
while i < n:
	j = i
	tmp = 0
	while j < n and a[j] == a[i]:
		j += 1
		tmp += 1
	s.append(tmp)
	i = j
pre = [0] * len(s)
pre[0] = s[0]
for i in range(1, len(s)):
	pre[i] = s[i]
	pre[i] += pre[i - 1]
ans = n + 5
for i in range(max(0, len(s) - req + 1)):
	ans = min(ans, n - (pre[i + req - 1] - pre[i] + s[i]))
if ans == n + 5:
	ans = 0
print(ans)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
limit = 2 ** (8 * m // n)
cnt = limit - len(set(arr))
ls = [0]
if cnt >= 0:
	print(0)
else:
	ma = 0
	for i in range(1, n):
		if arr[i] != arr[i - 1]:
			ls.append(i)
	for i in range(len(ls) - limit):
		ma = max(ma, ls[i + limit] - ls[i])
	print(n - ma)


import sys
input = sys.stdin.readline
from itertools import accumulate as acc
(n, m) = map(int, input().split())
m = m * 8 // n
mx = 2 ** m
a = list(map(int, input().split()))
(c, d) = ({}, [])
for i in a:
	if i not in c:
		c[i] = 1
		d.append(i)
	else:
		c[i] += 1
d.sort()
d = [c[i] for i in d]
d = list(acc(d))
ans = 0
for i in range(min(mx - 1, len(d) - 1), len(d)):
	s = d[i]
	if i >= mx:
		s -= d[i - mx]
	ans = max(ans, s)
print(n - ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

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

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

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 ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
inf = pow(10, 20)
mod = 10 ** 9 + 7

def bucketsort(order, seq):
	buckets = [0] * (max(seq) + 1)
	for x in seq:
		buckets[x] += 1
	for i in range(len(buckets) - 1):
		buckets[i + 1] += buckets[i]
	new_order = [-1] * len(seq)
	for i in reversed(order):
		x = seq[i]
		idx = buckets[x] = buckets[x] - 1
		new_order[idx] = i
	return new_order

def ordersort(order, seq, reverse=False):
	bit = max(seq).bit_length() >> 1
	mask = (1 << bit) - 1
	order = bucketsort(order, [x & mask for x in seq])
	order = bucketsort(order, [x >> bit for x in seq])
	if reverse:
		order.reverse()
	return order

def long_ordersort(order, seq):
	order = ordersort(order, [int(i & 2147483647) for i in seq])
	return ordersort(order, [int(i >> 31) for i in seq])

def multikey_ordersort(order, *seqs, sort=ordersort):
	for i in reversed(range(len(seqs))):
		order = sort(order, seqs[i])
	return order

def chck(mind, n, ii):
	cnt = 0
	while 2 ** cnt < mind:
		cnt += 1
	if n * cnt <= ii:
		return True
	return False

def solve(case):
	(n, ii) = sep()
	ii *= 8
	a = lis()
	cnt = {}
	for i in range(n):
		if a[i] not in cnt:
			cnt[a[i]] = 1
		else:
			cnt[a[i]] += 1
	req = 1
	lo = 1
	hi = 10 ** 9
	while lo <= hi:
		mid = (lo + hi) // 2
		if chck(mid, n, ii):
			req = max(req, mid)
			lo = mid + 1
		else:
			hi = mid - 1
	if req >= len(set(a)):
		print(0)
		return
	l = []
	r = []
	for i in cnt:
		l.append(i)
		r.append(cnt[i])
	order = multikey_ordersort(range(len(l)), l, r)
	curr = []
	for i in order:
		curr.append(r[i])
	ans = n - 1
	pre = [0] * (n + 1)
	for i in range(len(curr)):
		pre[i] = pre[i - 1] + curr[i]
	n = len(curr)
	for i in range(n):
		if i + req > n - 1:
			continue
		else:
			temp = pre[i - 1] + pre[n - 1] - pre[i + req - 1]
		ans = min(ans, temp)
	print(ans)
testcase(1)


from collections import defaultdict as dd
(n, I) = map(int, input().split())
l = list(map(int, input().split()))
ll = []
last = -1
l.sort()
for i in l:
	if i != last:
		ll.append(1)
		last = i
	else:
		ll[-1] += 1
k = len(ll)
while k > 1 << 8 * I // n:
	k -= 1
ans = 0
for i in range(k):
	ans += ll[i]
res = ans
for i in range(k, len(ll)):
	ans = ans + ll[i] - ll[i - k]
	res = max(res, ans)
print(sum(ll) - res)


(n, l) = map(int, input().split())
a = [*map(int, input().split())]
a.sort()
p = 8 * l // n
if p >= 20:
	print(0)
	exit()
x = 1 << p
v = []
prev = -1
for i in a:
	if i != prev:
		v.append(1)
	else:
		v[-1] += 1
	prev = i
from itertools import accumulate
s = [0] + [*accumulate(v[::-1])]
ans = 1000000000.0
temp = 0
for i in range(len(v)):
	ans = min(ans, temp + s[max(len(v) - i - x, 0)])
	temp += v[i]
print(ans)


import math
(n, m) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
a.sort()
lastval = -1
b = list()
for x in a:
	if x != lastval:
		b.append(1)
		lastval = x
	else:
		b[-1] += 1
k = len(b)
while k > 1 << 8 * m // n:
	k -= 1
ans = 0
for x in range(k):
	ans += b[x]
res = ans
for x in range(k, len(b)):
	res = res + b[x] - b[x - k]
	ans = max(res, ans)
print(n - ans)


from math import *
(n, I) = map(int, input().split())
a = sorted(list(map(int, input().split())))
I *= 8
now = 0
ctr = 1
ans = float('INF')
for i in range(n):
	if i != 0 and a[i] != a[i - 1] and (now >= i):
		ctr -= 1
	if now < i:
		now = i
		ctr = 1
	ctr = max(ctr, 1)
	while now != n - 1 and (a[now + 1] != a[now] and ceil(log2(ctr + 1)) * n <= I or (a[now + 1] == a[now] and ceil(log2(ctr)) * n <= I)):
		if a[now + 1] != a[now]:
			ctr += 1
		now += 1
	ans = min(ans, i + n - now - 1)
print(ans)


(n, I) = map(int, input().split())
a = list(map(int, input().split()))
b = I * 8 // n
c = 2 ** b
a.sort()
d = {}
for i in range(n):
	if a[i] in d:
		a[i] = d[a[i]]
	else:
		d[a[i]] = len(d)
		a[i] = d[a[i]]
(l, r) = (0, 0)
ans = n
while l < len(a):
	while r < len(a) and a[r] - a[l] + 1 <= c:
		r += 1
	ans = min(ans, n - (r - l))
	l += 1
print(ans)


import math
(n, m) = list(map(int, input().split()))
lst = list(map(int, input().split()))
lst.sort()
last_val = -1
freq_list = []
for i in range(n):
	if lst[i] != last_val:
		last_val = lst[i]
		freq_list.append(1)
	else:
		freq_list[-1] += 1
k = len(freq_list)
for i in range(k, 0, -1):
	if n * math.ceil(math.log2(i)) <= m * 8:
		k = i
		break
mx = 0
tot = sum(freq_list[:k])
mx = max(tot, mx)
for i in range(k, len(freq_list)):
	tot = tot + freq_list[i] - freq_list[i - k]
	mx = max(mx, tot)
print(n - mx)


(n, I) = map(int, input().strip().split())
numbers = list(map(int, input().strip().split()))
num_bytes = 8 * I // n
numbers.sort()
import math as mm
d = {}
lst = []
for k in range(0, len(numbers)):
	if numbers[k] in d.keys():
		d[numbers[k]] += 1
	else:
		d[numbers[k]] = 1
		lst.append(numbers[k])
qt = n - d[lst[-1]]
start = len(lst) - 1
end = len(lst)
changed = qt
while start >= 1:
	start -= 1
	qt -= d[lst[start]]
	while mm.ceil(mm.log2(end - start)) > num_bytes:
		end -= 1
		qt += d[lst[end]]
	if qt < changed:
		changed = qt
print(changed)


import math as mt
import collections as cc
import sys
I = lambda : list(map(int, input().split()))
(n, i) = I()
l = I()
l.sort()
tot = 2 ** (8 * i // n)
ans = -10
temp = [0]
for i in range(1, n):
	if l[i] != l[i - 1]:
		temp.append(i)
if len(temp) <= tot:
	print(0)
else:
	x = -1
	for i in range(len(temp) - tot):
		x = max(temp[i + tot] - temp[i], x)
	print(n - x)


import sys
(n, I) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
k_bits = 8 * I // n
K = pow(2, k_bits)
arr.sort()
b = [0]
for i in range(1, n):
	if arr[i] != arr[i - 1]:
		b.append(i)
if K >= len(b):
	print(0)
else:
	print(n - max((b[i + K] - b[i] for i in range(len(b) - K))))


(n, I) = [int(i) for i in input().split()]
a = sorted([int(i) for i in input().split()])
b = []
c_one_b = I * 8 // n
k = 2 ** c_one_b
c = 1
for i in range(n - 1):
	if a[i] != a[i + 1]:
		b.append(c)
		c = 0
	c += 1
b.append(c)
s = 0
maxx = 0
ln = len(b)
for j in range(min(k, ln)):
	s += b[j]
maxx = s
for i in range(min(ln, k), ln):
	if s > maxx:
		maxx = s
	s -= b[i - k]
	s += b[i]
print(n - maxx)


(n, I) = map(int, input().split())
a = list(map(int, input().split()))
diff = len(set(a))
k = 8 * I // n
K = 2 ** k
if diff < K:
	print(0)
else:
	a.sort()
	ind = 0
	curr = -1
	changes = []
	for i in range(n):
		if a[ind] != curr:
			changes.append(ind)
			curr = a[ind]
			ind += 1
		else:
			ind += 1
	b = a[::-1]
	ind = 0
	curr = -1
	changes1 = []
	for i in range(n):
		if b[ind] != curr:
			changes1.append(ind)
			curr = b[ind]
			ind += 1
		else:
			ind += 1
	mini = 10 ** 15
	for i in range(diff - K + 1):
		mini = min(mini, changes[i] + changes1[diff - K - i])
	print(mini)


def answer(n, x, A):
	k = 2 ** (x * 8 // n)
	A.sort()
	l = 0
	r = 0
	d = set()
	maxi = 0
	while r < n:
		if len(d) < k:
			d.add(A[r])
			r += 1
		elif len(d) == k:
			if A[r] in d:
				r += 1
			else:
				t = A[l]
				while r > l and A[l] == t:
					l += 1
				d.remove(t)
				d.add(A[r])
				r += 1
		maxi = max(maxi, r - l)
	return n - maxi
(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
print(answer(n, x, arr))


import atexit
import io
import sys
from collections import Counter
from math import log
import math
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
(n, i) = map(int, input().split())
l = list(map(int, input().split()))
k = 8 * i // n
K = 2 ** k
l.sort()
temp = [0]
for i in range(1, n):
	if l[i - 1] != l[i]:
		temp.append(i)
if len(temp) <= K:
	print(0)
else:
	print(n - max((temp[i + K] - temp[i] for i in range(len(temp) - K))))


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

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

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

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')

def lcm(a, b):
	return a * b // lcm(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd, log2
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	(n, i) = RL()
	arr = RLL()
	ct = Counter(arr)
	K = len(ct)
	k = ceil(log2(K))
	if i * 8 >= k * n:
		print(0)
	else:
		(l, r) = (0, K)

		def c(num):
			nowk = ceil(log2(num))
			if i * 8 >= nowk * n:
				return True
			else:
				return False
		while l < r:
			m = (l + r + 1) // 2
			if c(m):
				l = m
			else:
				r = m - 1
		sct = sorted(ct)
		sm = [0]
		for i in sct:
			sm.append(sm[-1] + ct[i])
		res = INF
		for i in range(len(ct)):
			if i + l >= len(sm):
				break
			now = sm[i + l] - sm[i]
			res = min(sm[-1] - now, res)
		print(res)
main()


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
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
R = lambda : map(int, input().split())
(n, I) = R()
a = sorted(R())
b = [0] + [i + 1 for i in range(n - 1) if a[i] < a[i + 1]] + [n]
print(n - max((y - x for (x, y) in zip(b, b[1 << 8 * I // n:])), default=n))


import os
import sys
from io import BytesIO, IOBase
from collections import Counter

def main():
	(n, I) = map(int, input().split())
	I *= 8
	a = list(map(int, input().split()))
	c = Counter(a)
	a = sorted(set(a))
	(y, ma, j, b, z) = (1 << min(I // n, 20), 0, 0, Counter(), 0)
	for i in range(len(a)):
		while j < len(a) and len(b) < y:
			b[a[j]] += 1
			z += c[a[j]]
			j += 1
		if len(b) == y or j == len(a):
			ma = max(ma, z)
		b[a[i]] -= 1
		z -= c[a[i]]
		if not b[a[i]]:
			del b[a[i]]
	print(n - ma)
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()


import math

def range_sum(l, r, pref_sums):
	return pref_sums[r + 1] - pref_sums[l]
(n, I) = [int(i) for i in input().split()]
I *= 8
mp3 = sorted([int(i) for i in input().split()])
max_n_freq = 2 ** math.floor(I / n)
changes = [1]
last_value = mp3[0]
for i in range(1, len(mp3)):
	if mp3[i] == last_value:
		changes[len(changes) - 1] += 1
	else:
		changes.append(1)
		last_value = mp3[i]
if len(changes) <= max_n_freq:
	print(0)
else:
	changes_pref_sums = [0, changes[0]]
	for i in range(1, len(changes)):
		changes_pref_sums.append(changes_pref_sums[len(changes_pref_sums) - 1] + changes[i])
	max_undistorted = max([range_sum(i, i + max_n_freq - 1, changes_pref_sums) for i in range(0, len(changes) - max_n_freq + 1)])
	print(changes_pref_sums[len(changes_pref_sums) - 1] - max_undistorted)


(n, I) = [int(i) for i in input().split()]
l1 = [int(i) for i in input().split()]
k = 8 * I // n
K = 2 ** k
l1.sort()
dstnct = []
dstnct.append(0)
for i in range(1, len(l1)):
	if l1[i] != l1[i - 1]:
		dstnct.append(i)
if len(dstnct) <= K:
	print(0)
else:
	print(n - max((dstnct[i + K] - dstnct[i] for i in range(len(dstnct) - K))))


import sys
input = sys.stdin.readline
(n, I) = map(int, input().split())
A = list(map(int, input().split()))
K = int(2 ** (I * 8 // n))
from collections import Counter
C = Counter(A)
KEY = sorted(C.keys())
LIST = []
for k in KEY:
	LIST.append(C[k])
S = [0]
for l in LIST:
	S.append(l + S[-1])
if K >= len(KEY):
	print(0)
	sys.exit()
ANS = S[-1]
SUM = S[-1]
for i in range(K, len(S)):
	ANS = min(ANS, SUM - (S[i] - S[i - K]))
print(ANS)


import math
M = 10 ** 9 + 7
R = lambda : map(int, input().split())
(n, I) = R()
L = sorted(R())
k = I * 8 // n
d = []
i = 0
j = 0
while i < n:
	j = i
	t = L[i]
	i += 1
	while i < n and L[i] == t:
		i += 1
	d.append([j, i - 1])
k = 2 ** k
res = n
for i in range(len(d)):
	p = min(k + i - 1, len(d) - 1)
	res = min(res, n - (d[p][1] - d[i][0] + 1))
print(res)


import math
(n, I) = map(int, input().split())
A = sorted(list(map(int, input().split())))
bits = I * 8
K = 2 ** (bits // n)
U = [A[0]]
S = [0]
a = A[0]
s = 1
for i in range(1, n):
	if A[i] != a:
		U.append(A[i])
		S.append(s)
	a = A[i]
	s += 1
S.append(s)
if K >= len(U):
	print(0)
else:
	ans = 10 ** 10
	for i in range(len(U) - K + 1):
		ans = min(ans, s - (S[i + K] - S[i]))
	print(ans)


(n, I) = map(int, input().split())
k = int(8 * I / n)
K = 2 ** k
a = sorted(map(int, input().split()))
nums = [1]
for c in range(1, n):
	if a[c] == a[c - 1]:
		nums[-1] += 1
	else:
		nums.append(1)
curr = sum(nums[:K])
m = curr
for i in range(0, len(nums) - K):
	curr = curr - nums[i] + nums[i + K]
	m = max(curr, m)
print(n - m)


import math
(n, i) = map(int, input().split())
a = list(map(int, input().split()))
k = 8 * i
a.sort()
f = a[0]
d = [0]
for i in range(n):
	if f == a[i]:
		d[-1] += 1
	else:
		d.append(1)
		f = a[i]
K = len(d)
while k < math.ceil(math.log2(K)) * n:
	K -= 1
t = sum(d[:K])
m = t
for i in range(K, len(d)):
	t += d[i] - d[i - K]
	m = max(t, m)
print(n - m)


from sys import stdin
input = stdin.readline
(n, I) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
k = 8 * I // n
K = 2 ** k
b = [0]
for i in range(1, n):
	if a[i - 1] != a[i]:
		b.append(i)
if len(b) <= K:
	print(0)
else:
	print(n - max((b[i + K] - b[i] for i in range(len(b) - K))))


from sys import *
from math import *
(n, K) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
k = 8 * K
x = k // n
d = 2 ** x
a.sort()
b = [a[0]]
for i in range(1, n):
	if a[i] != a[i - 1]:
		b.append(a[i])
if len(b) <= d:
	print(0)
else:
	cnt = [0] * len(b)
	f = {}
	for i in range(len(b)):
		f[b[i]] = i
	for i in range(n):
		cnt[f[a[i]]] += 1
	a1 = cnt[:d]
	s = sum(a1)
	j = 0
	k = 0
	ans = s
	for i in range(d, len(b)):
		s -= cnt[k]
		s += cnt[i]
		k += 1
		if ans < s:
			ans = s
	print(n - ans)


from collections import defaultdict
(n, s) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
m = 2 ** int(s * 8 / n)
D = defaultdict(lambda : 0)
value = 0
Max = 0
nb = 0
for i in range(n):
	if D[l[i]] == 0:
		D[l[i]] = 1
	else:
		D[l[i]] += 1
	nb += 1
	while len(D) > m:
		if D[l[value]] == 1:
			D.pop(l[value])
			nb -= 1
		else:
			D[l[value]] -= 1
			nb -= 1
		value += 1
	Max = max(Max, nb)
print(n - Max)


import math
(a, b) = map(int, input().split())
x = 8 * b // a
x = pow(2, x)
z = list(map(int, input().split()))
z.sort()
ans = []
count = 1
for i in range(1, len(z)):
	if z[i] == z[i - 1]:
		count += 1
	else:
		ans.append(count)
		count = 1
ans.append(count)
if len(ans) <= x:
	print(0)
	exit()
l = 0
total = sum(ans[0:x + l])
r = sum(ans)
mini = r - total
for i in range(1, len(ans) - x + 1):
	total = total - ans[i - 1] + ans[x + i - 1]
	mini = min(mini, r - total)
print(mini)


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')
import math
(n, i) = map(int, input().split())
vals = sorted(map(int, input().split()))
bits = 8 * i
dist = [vals[0]]
mult = [1]
for s in range(1, n):
	if vals[s] == dist[-1]:
		mult[-1] += 1
	else:
		dist.append(vals[s])
		mult.append(1)
q = len(dist)
k = 1
for s in range(q, 0, -1):
	num = math.ceil(math.log2(s)) * n
	if num <= bits:
		k = s
		break
pref = [mult[0]]
for s in range(1, q):
	pref.append(pref[-1] + mult[s])
suf = [mult[-1]]
for s in range(q - 2, -1, -1):
	suf.append(suf[-1] + mult[s])
nums = q - k
ans = 10 ** 9
for s in range(nums + 1):
	left = s
	right = nums - s
	cv = 0
	if left > 0:
		cv += pref[s - 1]
	if right > 0:
		cv += suf[right - 1]
	ans = min(ans, cv)
print(ans)


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
t = math.floor(8 * k / n)
K = 1
p = 2 ** t
b = []
cnt = 1
for i in range(n - 1):
	if a[i] != a[i + 1]:
		b.append(cnt)
		cnt = 1
	else:
		cnt += 1
if n > 1:
	if a[-1] == a[-2]:
		b.append(cnt)
	else:
		b.append(1)
if len(b) <= p:
	print(0)
	exit()
s = 0
for i in range(p):
	s += b[i]
c = []
c.append(n - s)
for i in range(p, len(b)):
	s += b[i]
	s -= b[i - p]
	c.append(n - s)
print(min(c))


import math
(n, m) = map(int, input().split())
lis = sorted(map(int, input().split()))
freq = []
last = -1
for i in range(n):
	if lis[i] != last:
		freq.append(1)
		last = lis[i]
	else:
		freq[-1] += 1
k = len(freq)
for i in range(k, 0, -1):
	if n * math.ceil(math.log2(i)) <= m * 8:
		k = i
		break
mx = sum(freq[:k])
tem = mx
for i in range(k, len(freq)):
	tem = tem + freq[i] - freq[i - k]
	mx = max(mx, tem)
print(n - mx)


(N, I) = map(int, input().split())
A = sorted([int(a) for a in input().split()])
B = []
j = 0
for i in range(N):
	if i == 0 or A[i] == A[i - 1]:
		B.append(j)
	else:
		j += 1
		B.append(j)

def calc(k):
	K = 1 << k
	i = 0
	j = 0
	ma = 0
	while j < N:
		if B[j] - B[i] <= K - 1:
			ma = max(ma, j - i + 1)
			j += 1
		else:
			i += 1
	return N - ma
ans = 10 ** 100
for i in range(31):
	if i * N <= 8 * I:
		ans = min(ans, calc(i))
print(ans)


(n, I) = [int(x) for x in input().split()]
d = pow(2, 8 * I // n)
a = [int(x) for x in input().split()]
a.sort()
val = [0]
m = 0
for i in range(1, n):
	if a[i - 1] != a[i]:
		val.append(i)
diff = len(val) - d
if len(val) <= d:
	print('0')
else:
	for i in range(diff):
		m = max(val[i + d] - val[i], m)
	print(n - m)


vec_a = []
freq = []
cum_freq = []
(n, available_bytes) = map(int, input().split())
vec_a = list(map(int, input().split()))
vec_a.sort()
a = vec_a[0]
freq.append(1)
for i in range(1, n):
	if vec_a[i] == a:
		freq[-1] += 1
	else:
		a = vec_a[i]
		freq.append(1)
tot_distinct_num = len(freq)
total = 0
for f in freq:
	total += f
	cum_freq.append(total)
each_num_occupied_bits = available_bytes * 8 // n
tot_distinct_num_capable = 1 << min(each_num_occupied_bits, 20)
unchanged_count = 0
for i in range(min(tot_distinct_num_capable, tot_distinct_num) - 1, tot_distinct_num):
	s = i - tot_distinct_num_capable
	less = 0 if s < 0 else cum_freq[s]
	curr_unchanged_cout = cum_freq[i] - less
	unchanged_count = max(unchanged_count, curr_unchanged_cout)
print(n - unchanged_count)


from collections import Counter
from math import ceil, log2, floor, pow
[n, i] = [int(x) for x in input().split()]
maxbits = 8 * i
arr = [int(x) for x in input().split()]
fr = Counter(arr)
arr1 = sorted(fr.keys())
t = K = len(arr1)
k = ceil(log2(K))
if n * k <= maxbits:
	print(0)
else:
	k = floor(maxbits / n)
	K = 2 ** k
	su = sum([fr[arr1[x]] for x in range(t)])
	i = 0
	j = K - 1
	ma = -1
	temp = sum([fr[arr1[x]] for x in range(i, j + 1)])
	while j < t:
		if temp > ma:
			ma = temp
		i += 1
		j += 1
		if j >= t:
			break
		temp = temp - fr[arr1[i - 1]] + fr[arr1[j]]
	print(su - ma)


import sys
import math
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
import heapq
infinite = float('inf')
(n, I) = RI()
l = RI()
d = {}
for i in l:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
size = len(d)
reqb = I * 8
totalbitsperchar = reqb // n
maxunique = 2 ** totalbitsperchar
elementstoremove = size - maxunique
if elementstoremove <= 0:
	print(0)
else:
	h = []
	for i in d:
		h.append(i)
	h.sort()
	s = len(h)
	mini = 0
	for i in range(elementstoremove):
		mini += d[h[i]]
	cur = mini
	i = 0
	j = s
	while i <= elementstoremove:
		i += 1
		j -= 1
		temp = cur - d[h[elementstoremove - i]] + d[h[j]]
		cur = temp
		mini = min(mini, temp)
	print(mini)


dic = {}
num = 0
a = [0]
sum1 = [0]
sum2 = [0]

def getID(x):
	global dic, num
	if dic.get(x, -1) == -1:
		num += 1
		dic[x] = num
	return dic[x]

def quickM(d):
	ans = 1
	base = 2
	while d > 0:
		if d & 1:
			ans *= base
		base *= base
		d >>= 1
	return ans
(n, I) = list(map(lambda x: int(x), input().split(' ')))
aa = input().split(' ')
for i in range(n):
	aa[i] = int(aa[i])
aa.sort()
num = 1
a.append(1)
for i in range(1, n):
	if aa[i] == aa[i - 1]:
		a[num] += 1
	else:
		num += 1
		a.append(1)
for i in range(1, num + 1):
	sum1.append(sum1[i - 1] + a[i])
	sum2.append(sum2[i - 1] + a[num - i + 1])
K = num
k = I * 8 // n
if k > 30:
	k = 30
cnt = K - quickM(k)
if cnt < 0:
	print(0)
else:
	ans = n - 1
	for i in range(cnt + 1):
		ans = min(ans, sum1[i] + sum2[cnt - i])
		ans = min(ans, sum2[i] + sum1[cnt - i])
	print(ans)


(n, I) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
count = 0
for i in range(n):
	if a[i] not in d:
		count += 1
		d[a[i]] = 1
	else:
		d[a[i]] += 1
ash = list(set(a))
ash.sort()
import math
if math.ceil(math.log2(count)) * n <= I * 8:
	print(0)
else:
	k = pow(2, I * 8 // n)
	mi = -1
	l = ash[:k]
	su = 0
	for j in l:
		su += d[j]
	if mi < su:
		mi = su
	for i in range(1, len(ash) - k + 1):
		su = su - d[ash[i - 1]] + d[ash[i + k - 1]]
		if mi < su:
			mi = su
	if mi < su:
		mi = su
	if n - mi == 134454:
		print(k)
	print(n - mi)


import math
import collections
(n, I) = input().split()
(n, I) = [int(n), int(I)]
k = 8 * I // n
K = 2 ** k
l = [int(i) for i in input().split()]
l.sort()
b = [0]
for i in range(1, n):
	if l[i - 1] != l[i]:
		b.append(i)
s = len(set(l))
count = []
index = n
if s <= K:
	print(0)
else:
	for i in range(len(b) - K):
		count.append(b[i + K] - b[i])
	print(n - max(count))


ni = input()
(n, i) = list(map(int, ni.split()))
nums = input()
nums = list(map(int, nums.split()))
i = i * 8
mm = {}
for k in nums:
	if k in mm:
		mm[k] += 1
	else:
		mm[k] = 1
keys = mm.keys()
s_keys = sorted(list(keys))
bits = i // n
nums_len = pow(2, bits)
right = nums_len
left = 0
if right >= len(s_keys):
	print(0)
else:
	min_change = 999999
	now_change = 0
	for k in s_keys[right:]:
		now_change += mm[k]
	while right < len(s_keys):
		if now_change < min_change:
			min_change = now_change
		now_change += mm[s_keys[left]]
		now_change -= mm[s_keys[right]]
		left += 1
		right += 1
	print(min_change)


import collections as col

def getInts():
	return [int(s) for s in input().split()]

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

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, i) = getInts()
	I = 8 * i
	A = getInts()
	if I // N > 20:
		return 0
	K = pow(2, I // N)
	A.sort()
	B = []
	curr = 1
	for n in range(1, N):
		if A[n] == A[n - 1]:
			curr += 1
		else:
			B.append(curr)
			curr = 1
	B.append(curr)
	L = len(B)
	if L <= K:
		return 0
	x = sum(B[:K])
	ans = N - x
	for j in range(K, L):
		x += B[j]
		x -= B[j - K]
		ans = min(ans, N - x)
	return ans
print(solve())


from math import *
(n, o) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
m = []
for i in range(n):
	if i == 0:
		pr = a[i]
		p = 1
	elif pr != a[i]:
		m.append(p)
		p = 1
	else:
		p += 1
	pr = a[i]
m.append(p)
r = len(m) - 1
while ceil(log2(r + 1)) * n > o * 8:
	r -= 1
l = 0
viv = 0
while l <= r:
	viv += m[l]
	l += 1
l = 0
mv = n - viv
while r < len(m) - 1:
	if n - viv < mv:
		mv = n - viv
	r += 1
	viv += m[r]
	viv -= m[l]
	l += 1
print(mv)


import math
(n, k) = map(int, input().split())
if k / n >= 31:
	print('0')
	exit()
disti = math.floor(2 ** math.floor(8 * k / n))
a = list(map(int, input().split()))
if len(set(a)) <= disti:
	print('0')
	exit()
a = sorted(a)
d = dict()
for i in range(len(a)):
	d[a[i]] = d.get(a[i], 0)
	d[a[i]] += 1
p = []
for i in sorted(d.keys()):
	p.append(d[i])
ans = 0
for i in range(disti):
	ans += p[i]
window = ans
for i in range(disti, len(p)):
	window -= p[i - disti]
	window += p[i]
	if window > ans:
		ans = window
print(sum(p) - ans)


import os
import sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd, log
from collections import *
from bisect import *
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')
g = lambda : input().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()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(n, I) = gil()
I *= 8
a = gil()
a.sort()
cnt = 0
l = 0
while l < n:
	val = a[l]
	while l < n and a[l] == val:
		a[l] = cnt
		l += 1
	cnt += 1
ans = n - 1
(l, r) = (0, -1)
maxDiff = pow(2, I // n)
while l < n and r < n:
	while r + 1 < n and a[r + 1] - a[l] + 1 <= maxDiff:
		r += 1
	ans = min(ans, n - (r - l + 1))
	l += 1
print(ans)


import sys
import math

def findans(pref, n, num, count, tmp):
	mini = -2
	mid = num
	for g in range(len(pref) - 1 - mid + 1):
		start = pref[g] - pref[0]
		end = pref[len(pref) - 1] - pref[g + mid]
		if mini == -2:
			mini = start + end
		else:
			mini = min(mini, start + end)
	return mini

def b_search(a, h, pref, n, I, tmp):
	low = 1
	high = h
	while low < high:
		mid = low + math.ceil((high - low) / 2)
		val = math.ceil(math.log(mid, 2)) * n
		if val <= I * 8:
			low = mid
		else:
			high = mid - 1
	return findans(pref, n, low, h, tmp)
[n, I] = [int(i) for i in sys.stdin.readline().split()]
a = [int(j) for j in sys.stdin.readline().split()]
a.sort()
prev = -2
count = 0
arr = []
for i in range(n):
	if prev != a[i]:
		count += 1
		arr.append([a[i], 1])
	else:
		arr[-1][1] += 1
	prev = a[i]
tmp = []
for p in range(len(arr)):
	tmp.append(arr[p][1])
pref = [0]
for r in range(len(arr)):
	pref.append(pref[r] + arr[r][1])
if math.ceil(math.log(count, 2)) * n <= I * 8:
	print(0)
else:
	print(b_search(a, count, pref, n, I, tmp))


from collections import Counter
(n, I) = map(int, input().split())
bits = 2 ** (I * 8 // n)
A = list(map(int, input().split()))
counter = Counter(A)
maxans = -1
keys = sorted(counter.keys())
lk = len(keys)
s = [0] * lk
s[0] = counter[keys[0]]
for (i, k) in enumerate(keys[1:], 1):
	s[i] = s[i - 1] + counter[k]
if lk <= bits:
	print(0)
else:
	for l in range(lk - bits):
		maxans = max(maxans, s[l + bits] - s[l])
	print(n - maxans)


def solve():
	(n, i) = map(int, input().split())
	ns = sorted([*map(int, input().split())])
	k = 1 << i * 8 // n
	lis = []
	for i in range(n - 1):
		if ns[i] != ns[i + 1]:
			lis.append(i + 1)
	lis.append(n)
	print(0 if len(lis) <= k else n - max((lis[i + k] - lis[i] for i in range(len(lis) - k))))
solve()


(n, I) = map(int, input().split())
a = list(map(int, input().split()))
k = 2 ** (I * 8 // n)
a.sort()
ls = []
cnt = 1
for i in range(1, n):
	if a[i] == a[i - 1]:
		cnt += 1
	else:
		ls.append([cnt, a[i - 1]])
		cnt = 1
if cnt:
	ls.append([cnt, a[-1]])
dis = len(ls)
if dis <= k:
	print(0)
else:
	prefix = [0 for i in range(len(ls) + 1)]
	for i in range(1, len(ls) + 1):
		prefix[i] = prefix[i - 1] + ls[i - 1][0]
	suffix = [0 for i in range(len(ls) + 1)]
	for i in range(len(ls) - 1, -1, -1):
		suffix[i] = suffix[i + 1] + ls[i][0]
	ans = n
	for i in range(dis - k + 1):
		ans = min(ans, prefix[i] + suffix[len(ls) - dis + k + i])
	print(ans)


import sys, math
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n, i) = I()
l = I()
k = i * 8 // n
a = []
l.sort()
c = 1
for i in range(n - 1):
	if l[i] != l[i + 1]:
		a.append(c)
		c = 1
	else:
		c += 1
a.append(c)
c = len(a)
ck = math.ceil(math.log2(c))
if k >= ck:
	print(0)
else:
	d = 2 ** k
	p = len(a)
	x = sum(a[:d])
	an = x
	for i in range(d, p):
		x = x - a[i - d] + a[i]
		an = max(an, x)
	print(n - an)


import sys
(n, I) = map(int, sys.stdin.readline().split())
s = list(map(int, sys.stdin.readline().split()))
k = I * 8 // n
s.sort()
c = [0]
for i in range(1, n):
	if s[i] != s[i - 1]:
		c.append(i)
k = 2 ** k
maxn = -1
for i in range(0, len(c) - k):
	maxn = max(maxn, c[i + k] - c[i])
if maxn == -1:
	print(0)
else:
	ans = n - maxn
	print(ans)


(n, _i) = map(int, input().split())
_i = _i * 8 // n
a = [int(_) for _ in input().split()]
a.sort()
p = 1
while _i > 0 and p <= 10000000.0:
	p <<= 1
	_i -= 1
x = 1
c = 1
v = 0
for i in range(1, n):
	if a[i] != a[i - 1]:
		c += 1
	if c > p:
		while a[v] == a[v + 1] and v < n - 1:
			v += 1
		v += 1
		c -= 1
	x = max(x, i - v + 1)
print(n - x)


import sys
import math
(n, y) = list(map(int, sys.stdin.readline().strip().split()))
a = list(map(int, sys.stdin.readline().strip().split()))
a.sort()
a.append(0)
y = y * 8
arr = []
i = 0
k = 2 ** (y // n)
while i < n:
	x = 1
	while a[i] == a[i + 1] and i < n:
		x += 1
		i += 1
	arr.append(x)
	i += 1
arr = [0] + arr
for i in range(1, len(arr)):
	arr[i] = arr[i] + arr[i - 1]
op = n
if len(arr) < k:
	print(0)
	exit(0)
for i in range(1, len(arr)):
	if i < k:
		xxx = arr[i] - arr[i - 1]
	else:
		xxx = arr[i] - arr[i - k]
	op = min(op, n - xxx)
print(op)


import sys
input = sys.stdin.readline
from math import log
from collections import deque
(n, i) = map(int, input().split())
l = list(map(int, input().split()))
if len(set(l)) == 1:
	print(0)
	exit(0)
quota = 8 * i // n
k = 1
if quota < 1:
	pass
else:
	k = 2 ** quota
l = sorted(l)
a = l[0]
b = 1
d = deque()
d.append(a)
i = 1
ans = 1
cnt = 1
while i < n:
	x = l[i]
	if x != d[-1]:
		if b == k:
			y = d[0]
			while d[0] == y:
				d.popleft()
				cnt -= 1
				if d == deque():
					cnt = 0
					break
			d.append(x)
			cnt += 1
		else:
			d.append(x)
			cnt += 1
			b += 1
	else:
		d.append(x)
		cnt += 1
	ans = max(cnt, ans)
	i += 1
print(n - ans)


import sys
import math as mt
input = sys.stdin.buffer.readline
t = 1
for _ in range(t):
	(n, I) = map(int, input().split())
	l = list(map(int, input().split()))
	x = I * 8 // n
	x = 2 ** x
	d = {}
	l.sort()
	for i in l:
		d[i] = d.get(i, 0) + 1
	if len(d) > x:
		pref = []
		pref.append(0)
		pref.append(d[l[0]])
		for i in range(1, n):
			if l[i] != l[i - 1]:
				pref.append(pref[-1] + d[l[i]])
		mini = pref[-1]
		for i in range(x, len(pref)):
			if mini > pref[-1] - (pref[i] - pref[i - x]):
				mini = pref[-1] - (pref[i] - pref[i - x])
		print(mini)
	else:
		print(0)


import sys
from collections import defaultdict
input = sys.stdin.readline

def main():
	(n, I) = map(int, input().split())
	a = list(map(int, input().split()))
	K = 2 ** min(20, 8 * I // n)
	a.sort()
	c = []
	pos = 0
	while pos < n:
		r = pos
		while r + 1 < n and a[pos] == a[r + 1]:
			r += 1
		c.append(r - pos + 1)
		pos = r + 1
	if K > len(c):
		print(0)
	else:
		pref = c.copy()
		suff = c.copy()
		for i in range(1, len(c)):
			pref[i] += pref[i - 1]
		for i in range(len(c) - 2, -1, -1):
			suff[i] += suff[i + 1]
		res = sum(c)
		l = 0
		r = K - 1
		while r < len(c):
			s1 = 0 if l == 0 else pref[l - 1]
			s2 = 0 if r == len(c) - 1 else suff[r + 1]
			res = min(res, s1 + s2)
			l += 1
			r += 1
		print(res)
main()


(n, I) = map(int, input().split())
I *= 8
array = list(map(int, input().split()))

def log(x):
	l = 0
	while 2 ** l < x:
		l += 1
	return l
array.sort()
izn = []
d = {}
for el in array:
	if el in d:
		d[el] += 1
	else:
		d[el] = 1
		izn.append(el)
f = len(izn)
j = 0
pos = 0
count = 0
un = 0
for i in range(f):
	while j < f and log(un + 1) * n <= I:
		count += d[izn[j]]
		if pos < count:
			pos = count
		j += 1
		un += 1
	un -= 1
	count -= d[izn[i]]
print(n - pos)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
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')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return 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(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def reVal(num):
	if num >= 0 and num <= 9:
		return chr(num + ord('0'))
	else:
		return chr(num - 10 + ord('A'))

def strev(str):
	len = len(str)
	for i in range(int(len / 2)):
		temp = str[i]
		str[i] = str[len - i - 1]
		str[len - i - 1] = temp

def fromDeci(res, base, inputNum):
	index = 0
	while inputNum > 0:
		res += reVal(inputNum % base)
		inputNum = int(inputNum / base)
	res = res[::-1]
	return res

def norm(s, l):
	tba = '0' * (l - len(s))
	return tba + s
(n, s) = map(int, input().split())
l = list(map(int, input().split()))
dis = 2 ** (8 * s // n)
if len(set(l)) <= dis:
	print(0)
else:
	f = [1]
	l.sort()
	for i in range(1, n):
		if l[i] == l[i - 1]:
			f[-1] += 1
		else:
			f.append(1)
	pre = [0]
	for i in range(0, len(f)):
		pre.append(pre[i] + f[i])
	suf = [0]
	lf = len(f)
	for i in range(lf - 1, -1, -1):
		suf.append(suf[lf - i - 1] + f[i])
	suf = suf[::-1]
	a = 10000000000
	for i in range(0, lf - dis):
		lp = i
		rp = lp + dis
		a = min(a, pre[lp] + suf[rp])
	print(a)


(n, i) = map(int, input().split())
l = list(map(int, input().split()))
k = 8 * i // n
K = 2 ** k
l.sort()
temp = [0]
for i in range(1, n):
	if l[i - 1] != l[i]:
		temp.append(i)
if len(temp) <= K:
	print(0)
else:
	print(n - max((temp[i + K] - temp[i] for i in range(len(temp) - K))))


from math import *
(n, I) = list(map(int, input().split()))
arr = list(map(int, input().split()))
I *= 8
arr.sort()
freqA = [[arr[0], 1]]
for i in range(1, n):
	if arr[i] == arr[i - 1]:
		freqA[-1][1] += 1
	else:
		freqA.append([arr[i], 1])
K = len(freqA)
k = int(ceil(log2(K)))
if n * k < I:
	print(0)
	exit(0)
changes = float('inf')
enoughK = int(pow(2, int(floor(I / n))))
enoughK = int(enoughK)
leftFreq = [freqA[0][1]]
rightFreq = [freqA[-1][1]]
for i in range(1, len(freqA)):
	leftFreq.append(leftFreq[i - 1] + freqA[i][1])
	rightFreq.append(rightFreq[i - 1] + freqA[len(freqA) - i - 1][1])
KK = len(freqA) - enoughK
for left in range(0, KK + 1):
	right = KK - left
	possibleChanges = 0
	if left != 0:
		possibleChanges += leftFreq[left - 1]
	if right != 0:
		possibleChanges += rightFreq[right - 1]
	changes = min(changes, possibleChanges)
if changes == float('inf'):
	changes = 0
print(changes)


import sys
import os
import io
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
import math

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 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 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 li():
	return list(map(int, input().split()))
t = 1
for _ in range(t):
	(n, I) = li()
	l = li()
	k = 2 ** min(8 * I // n, 20)
	dic = defaultdict(lambda : 0)
	for i in l:
		dic[i] += 1
	if len(list(set(l))) <= k:
		print(0)
	else:
		ans = 0
		temp = [0]
		l.sort()
		for i in range(1, n):
			if l[i] != l[i - 1]:
				temp.append(i)
		for i in range(len(temp) - k):
			ans = max(ans, temp[i + k] - temp[i])
		print(n - ans)


from sys import stdin
from sys import setrecursionlimit as SRL
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda : map(int, rd().strip().split())
(n, i) = rrd()
i *= 8
can = 2 ** (i // n)
a = list(rrd())
a.sort()
a = [-1] + a + [-1]
ans = 10 ** 100
j = 1
cnt = 0
for i in range(n + 1):
	if i and a[i] != a[i - 1]:
		cnt += 1
	if cnt > can:
		ans = min(ans, n - (i - j))
		j += 1
		while a[j] == a[j - 1]:
			j += 1
		cnt -= 1
ans = min(ans, n - (i + 1 - j))
print(ans)


(n, bs) = map(int, input().split())
a = list(map(int, input().split()))
k = bs * 8 // n
k = min(k, 30)
kd = 2 ** k
d = {}
for i in a:
	if i not in d:
		d[i] = 0
	d[i] += 1
cm = 0
a = sorted(set(a))
for i in a:
	ncm = cm + d[i]
	d[i] = cm
	cm = ncm
la = len(a)
ans = n
for l in range(la):
	r = l + kd
	lc = d[a[l]]
	if r < la:
		rc = d[a[r]]
	else:
		rc = n
	ans = min(ans, n - (rc - lc))
print(ans)


(n, I) = map(int, input().split())
audio_list = list(map(int, input().split()))
K = pow(2, 8 * I // n)
audio_dict = {}
for el in audio_list:
	if el not in audio_dict:
		audio_dict[el] = 1
	else:
		audio_dict[el] += 1
audio_keys = sorted(list(audio_dict.keys()))
audio = [audio_dict[el] for el in audio_keys]
if K >= len(audio):
	print(0)
else:
	count = len(audio) - K
	result = temp = sum(audio[:count])
	for i in range(count):
		temp += audio[~i] - audio[count - 1 - i]
		if temp < result:
			result = temp
	print(result)


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
(n, k) = R()
mn = 2 ** (k * 8 // n)
k = 0
lst = -1
a = []
for i in sorted(R()):
	if i != lst:
		a += (0,)
		k += 1
	a[-1] += 1
	lst = i
if k <= mn:
	print(0)
	exit()
ans = 0
for i in range(mn):
	ans += a[i]
val = ans
for i in range(mn, k):
	val += a[i]
	val -= a[i - mn]
	ans = max(ans, val)
print(sum(a) - ans)


(n, l) = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
num = len(set(a))
arr = 2 ** (8 * l // n)
a.append(10 ** 100)
b = []
counter = 1
for i in range(1, n + 1):
	if a[i] == a[i - 1]:
		counter += 1
	else:
		b.append(counter)
		counter = 1
pref = [0]
for item in b:
	pref.append(pref[-1] + item)
c = max(num - arr, 0)
lena = len(pref)
answer = 10 ** 100
for i in range(c + 1):
	answer = min(answer, pref[i] + pref[lena - 1] - pref[lena - c + i - 1])
print(answer)


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'
M = 998244353
EPS = 1e-06

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, I) = value()
a = sorted(array())
set_a = sorted(set(a))
C = Counter(a)
I *= 8
I //= n
if I > 20:
	Ma = n
else:
	Ma = 2 ** I
have = []
for i in set_a:
	have.append(C[i])
need = max(len(have) - Ma, 0)
ans = sum(have[:need])
ind = len(have) - 1
cur = ans
for i in range(need - 1, -1, -1):
	cur -= have[i]
	cur += have[ind]
	ind -= 1
	ans = min(ans, cur)
print(ans)


import math
(n, I) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a) + [-1]
cnt = 1
li = []
for i in range(n):
	if a[i] == a[i + 1]:
		cnt += 1
	if a[i] != a[i + 1]:
		li.append(cnt)
		cnt = 1
ok = 1
ng = n + 1
while abs(ok - ng) > 1:
	mid = (ok + ng) // 2
	if n * (mid - 1).bit_length() <= 8 * I:
		ok = mid
	else:
		ng = mid
ans = 0
for i in range(min(ok, len(li))):
	ans += li[i]
_sum = ans
i = 0
while i + ok < len(li):
	tmp = _sum
	tmp -= li[i]
	tmp += li[i + ok]
	ans = max(tmp, ans)
	_sum = tmp
	i += 1
print(n - ans)


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, I) = ria()
		a = ria()
		d = Counter(a)
		a = sorted(list(set(a)))
		limit = I * 8
		g = len(d)
		while True:
			k = math.ceil(math.log2(g))
			now = n * k
			if now <= limit:
				break
			g -= 1
		pres = [0]
		prevn = n
		n = len(a)
		for i in a:
			pres.append(pres[-1] + d[i])
		ans = 0
		for i in range(g, n + 1):
			ans = max(ans, pres[i] - pres[i - g])
		print(prevn - ans)
	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()


import math
from math import *
line1 = input()
(l, r) = line1.split()
l = int(l)
r = int(r)
arr = list(map(int, input().split()))
counts = []
elems = []
arr = sorted(arr)
elems.append(-1)
counts.append(0)
for elem in arr:
	if elem == elems[-1]:
		counts[-1] += 1
	else:
		elems.append(elem)
		counts.append(1)
elems = elems[1:]
counts = counts[1:]
K = len(counts)
k = 8 * r // l
N = 2 ** k
D = K - N
counts1 = counts
counts2 = counts.copy()
for k in range(1, len(counts1)):
	counts1[k] += counts1[k - 1]
	counts2[len(counts2) - 1 - k] += counts2[len(counts2) - k]
counts1 = [0] + counts1
counts2 = counts2 + [0]
if D <= 0:
	s = 0
else:
	s = 2 * 10 ** 9
	for i in range(D):
		s = min(s, counts1[i] + counts2[len(counts2) + i - 1 - D])
print(s)


from math import ceil, log2
from collections import Counter

def read():
	return [int(i) for i in input().split()]
for _ in range(1):
	(n, x) = read()
	d = Counter(list(read()))
	l = list(d.keys())
	l.sort()
	dis = K = len(l)
	while ceil(log2(K)) * n > x * 8:
		K -= 1
	K = dis - K
	s = sum([d[l[i]] for i in range(dis - K, dis)])
	c = s
	for i in range(K):
		c = c + d[l[i]] - d[l[-K + i]]
		s = min(s, c)
	print(s)


import sys
from collections import defaultdict as dd
pl = 1
from math import *
import copy
if pl:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(xxx) for xxx in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())
d = []
from bisect import *
from itertools import permutations
from bisect import *
(n, I) = mi()
a = li()
K = 8 * I // n
k = 2 ** K
l = 0
r = max(a) + 1
gg = n
a.sort()
d = []
i = 0
while i < n:
	j = i
	while i < n and a[i] == a[j]:
		i += 1
	d.append(i - j)
pre = [0, d[0]]
for i in range(1, len(d)):
	pre.append(pre[-1] + d[i])
for i in range(1, len(pre)):
	if i + k >= len(pre):
		gg = min(gg, pre[i - 1])
	else:
		gg = min(gg, pre[i - 1] + pre[-1] - pre[i + k - 1])
print(gg)


from sys import stdin
from collections import defaultdict
input = stdin.readline
(n, I) = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
d = defaultdict(int)
for v in a:
	d[v] += 1
d = sorted(d.items())
k = min(n, 2 ** int(8 * I / n))
off = len(d) - k
if off <= 0 or n == 1:
	print(0)
elif off == 1:
	print(min(d[0][1], d[-1][1]))
else:
	K = len(d)
	ls = [d[0][1]]
	for i in range(1, off):
		ls.append(ls[-1] + d[i][1])
	rs = [d[-1][1]]
	for i in range(K - 2, K - off - 1, -1):
		rs.append(rs[-1] + d[i][1])
	m = min(ls[off - 1], rs[off - 1])
	l = off - 1
	r = -1
	for i in range(off - 1):
		l -= 1
		r += 1
		s = ls[l] + rs[r]
		if s < m:
			m = s
	print(m)


from collections import defaultdict
(n, I) = [int(w) for w in input().split()]
l = [int(w) for w in input().split()]
k = 8 * I // n
K = 2 ** k
l.sort()
pref = [0]
hash = defaultdict(int)
for i in l:
	hash[i] += 1
for i in hash.keys():
	pref.append(pref[-1] + hash[i])
mini = -10
d = len(pref) - 1 - K
mini = 10 ** 18
for i in range(d):
	ele1 = i
	ele2 = d - i
	a = pref[ele1]
	b = abs(pref[len(pref) - ele2 - 1] - pref[len(pref) - 1])
	mini = min(a + b, mini)
if mini == 10 ** 18:
	print(0)
else:
	print(mini)


(n, I) = map(int, input().split())
all_a = list(map(int, input().split()))
amounts_a = {}
for a in all_a:
	if a in amounts_a.keys():
		amounts_a[a] += 1
	else:
		amounts_a[a] = 1
nums = list(amounts_a.keys())
nums.sort()
K = 2 ** min(20, 8 * I // n)
if len(nums) <= K:
	damaged = 0
else:
	good = 0
	for i in range(K):
		good += amounts_a[nums[i]]
	max_good = good
	for i in range(K, len(nums)):
		good += amounts_a[nums[i]] - amounts_a[nums[i - K]]
		max_good = max(max_good, good)
	damaged = n - max_good
print(damaged)


from collections import Counter
import operator
(n, I) = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
A = list(sorted(A))
max_k = 2 ** (I * 8 // n)
counter = Counter(A)
values = list(counter.items())
values.sort(key=operator.itemgetter(0))
k = len(values)
values2remove = max(0, k - max_k)
if values2remove == 0:
	print(0)
else:
	first_half = [0] * (values2remove + 1)
	second_half = [0] * (values2remove + 1)
	for x in range(1, values2remove + 1):
		first_half[x] = first_half[x - 1] + values[x - 1][1]
		second_half[x] = second_half[x - 1] + values[len(values) - x][1]
	min_value = (4 * 10 ** 5 + 1) ** 2
	for x in range(len(first_half)):
		min_value = min(min_value, first_half[x] + second_half[values2remove - x])
	print(min_value)


import math
(n, I) = map(int, input().split())
if I >= n * round(math.log(n, 2) + 0.5) / 8:
	print(0)
else:
	a = sorted([x for x in map(int, input().split())])
	a = [-1] + a
	b = [i for i in range(n) if a[i] < a[i + 1]]
	ans = set()
	for x in zip(b, b[2 ** (I * 8 // n):] + [n]):
		ans.add(x[1] - x[0])
	print(n - max(ans))


from sys import stdin
input = stdin.readline
(n, I) = map(int, input().split())
a = sorted(list(map(int, input().split())))
key = []
k = min(I * 8 // n, 20)
K = min(2 ** k, n)
last = -1
for i in range(n):
	if a[i] == last:
		key[-1] += 1
	else:
		key.append(1)
		last = a[i]
now = 0
best = 0
for i in range(len(key)):
	if i < K:
		now += key[i]
	else:
		now += key[i]
		now -= key[i - K]
	best = max(now, best)
print(n - best)


import sys

class CMP3:

	def solve(self):
		import math
		from bisect import bisect_left

		def nb_diff(a, l, r):
			return pre[r] - pre[l - 1] + int(l > 0 and a[l] == a[l - 1])
		(n, I) = [int(_) for _ in input().split()]
		a = [int(_) for _ in input().split()]
		a.sort()
		km = n
		if 8 * I // n <= math.log2(n):
			km = 2 ** (8 * I // n)
		ans = float('inf')
		pre = [0] * (n + 1)
		pre[0] = 1
		for i in range(1, n):
			pre[i] = pre[i - 1]
			if a[i] != a[i - 1]:
				pre[i] += 1
		d = len(set(a))
		for l in range(n):
			(lo, hi) = (l, n)
			while lo < hi:
				m = lo + hi >> 1
				if nb_diff(a, l, m) > km:
					hi = m
				else:
					lo = m + 1
			ans = min(ans, n - (lo - 1 - l + 1))
		print(ans)
solver = CMP3()
input = sys.stdin.readline
solver.solve()


import math

class Read:

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	(n, i) = Read.list_int()
	a = Read.list_int()
	maxK = 2 ** min(math.floor(i * 8 / n), 19)
	a.sort()
	d = {}
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	d = list(d.values())
	if maxK >= len(d):
		print(0)
		return
	s_max = 0
	for i in range(maxK):
		s_max += d[i]
	c_sum = s_max
	start = 0
	for i in range(maxK, len(d)):
		c_sum = c_sum - d[i - maxK] + d[i]
		if c_sum > s_max:
			s_max = c_sum
			start = i - maxK + 1
	result = 0
	for i in range(start, start + maxK):
		result += d[i]
	print(n - result)
query_count = 1
for j in range(query_count):
	solve()


(n, I) = map(int, input().split())
a = list(map(int, input().split()))
I *= 8
k = I // n
if k >= 20:
	res = 0
else:
	K = 2 ** k
	cc = {}
	for ai in a:
		cc[ai] = cc.get(ai, 0) + 1
	pres = []
	dd = sorted(cc)
	for i in dd:
		pres.append(cc[i])
	for i in range(1, len(pres)):
		pres[i] += pres[i - 1]
	if K >= len(pres):
		res = 0
	else:
		mm = 0
		for i in range(K, len(pres)):
			if mm < pres[i] - pres[i - K]:
				mm = pres[i] - pres[i - K]
		res = n - mm
print(res)


import atexit
import io
import sys
from collections import Counter
from math import log
import math
(n, i) = map(int, input().split())
l = list(map(int, input().split()))
k = 8 * i // n
K = 2 ** k
l.sort()
temp = [0]
for i in range(1, n):
	if l[i - 1] != l[i]:
		temp.append(i)
if len(temp) <= K:
	print(0)
else:
	print(n - max((temp[i + K] - temp[i] for i in range(len(temp) - K))))


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(n, p) = Neo()
x = Neo()
x.sort()
t = 2 ** (8 * p // n)
last = None
y = []
for c in x:
	if last is None or last != c:
		last = c
		y.append(1)
	else:
		y[-1] += 1
best = 0
now = 0
for i in range(len(y)):
	now += y[i]
	if i >= t:
		now -= y[i - t]
	best = max(best, now)
print(n - best)


from sys import stdin, stdout
input = stdin.readline
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.sort()
m = 2 ** (a[1] * 8 // len(b))
g = [0]
for i in range(1, a[0]):
	if b[i - 1] != b[i]:
		g.append(i)
if len(g) <= m:
	print(0)
else:
	print(a[0] - max((g[i + m] - g[i] for i in range(len(g) - m))))


import math
(n, I) = map(int, input().split())
arr = list(map(int, input().split()))
k = 8 * I // n
K = 2 ** k
arr.sort()
nd = 1
le = arr[0]
b = [0]
for i in range(1, n):
	if arr[i] != le:
		le = arr[i]
		b.append(i)
		nd += 1
b.append(n)
if K >= nd:
	print(0)
else:
	maxn = 0
	for i in range(K, nd):
		maxn = max(maxn, b[i] - b[i - K])
	print(n - maxn)


from sys import stdin
input = stdin.readline
from math import floor
(n, I) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
K = 2 ** floor(8 * I / n)
num_occ = dict()
for i in range(n):
	num_occ[a[i]] = num_occ.get(a[i], 0) + 1
if K >= len(num_occ):
	print(0)
else:
	sort_keys = sorted(num_occ.keys())
	sum_K = [0] * (len(sort_keys) - K + 1)
	acc_K = 0
	for i in range(K):
		acc_K += num_occ[sort_keys[i]]
	sum_K[0] = acc_K
	for i in range(K, len(sort_keys)):
		acc_K += num_occ[sort_keys[i]] - num_occ[sort_keys[i - K]]
		sum_K[i - K + 1] = acc_K
	print(n - max(sum_K))


(n, I) = list(map(int, input().strip().split()))
l = list(map(int, input().strip().split()))
l.sort()
k = 2 ** (I * 8 // n)
sol = []
i = 0
while i < n - 1:
	count = 1
	while i < n - 1 and l[i] == l[i + 1]:
		count += 1
		i += 1
	sol.append(count)
	i += 1
if len(l) > 1 and l[-1] != l[-2]:
	sol.append(1)
s = 0
i = 0
while i < k and i < len(sol):
	s += sol[i]
	i += 1
ll = 0
temp = s
while i < len(sol):
	temp += sol[i]
	temp -= sol[ll]
	if temp > s:
		s = temp
	i += 1
	ll += 1
if n - s < 0 or n == 1:
	print(0)
else:
	print(n - s)


from sys import stdin
from math import log2, ceil
from bisect import bisect_left as bl
(n, m) = map(int, stdin.readline().strip().split())
s = list(map(int, stdin.readline().strip().split()))
mx = 0
for i in range(1, n + 3):
	x = ceil(log2(i)) * n
	if ceil(x / 8) <= m:
		mx = i
	else:
		break
s.sort()
s1 = list(set(s.copy()))
s1.sort()
inf = 10 ** 9
ans = 10 ** 9
for i in range(len(s1)):
	x = s1[i]
	y = inf
	if i + mx < len(s1):
		y = s1[i + mx]
	ans = min(ans, n - (bl(s, y) - bl(s, x)))
print(ans)


import math
(n, i) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
k = 8 * i // n
K = 2 ** min(k, 30)
(i, j, ans) = (0, 0, n)
dist = 0
dct = {}
while i < n or j < n:
	if j == n:
		dct[l[i]] -= 1
		if dct[l[i]] == 0:
			del dct[l[i]]
		i += 1
	elif dist < K:
		if l[j] in dct:
			dct[l[j]] += 1
			j += 1
		else:
			dct[l[j]] = 1
			j += 1
			dist += 1
	elif dist == K:
		if l[j] in dct:
			dct[l[j]] += 1
			j += 1
		else:
			if dct[l[i]] == 1:
				del dct[l[i]]
				dist -= 1
			else:
				dct[l[i]] -= 1
			i += 1
	ans = min(ans, n - (j - i))
print(ans)


(n, I) = (*map(int, input().split()),)
a = [int(x) for x in input().split()]
a.sort()
tgtbpn = I * 8 // n
mxvals = 1 << tgtbpn
c = []
i = 0
while i < len(a):
	j = i
	cnt = 0
	while j < len(a) and a[j] == a[i]:
		cnt += 1
		j += 1
	c.append(cnt)
	i = j
sm = 0
mn = n
for i in range(len(c)):
	sm += c[i]
	if i - mxvals >= 0:
		sm -= c[i - mxvals]
	mn = min(mn, n - sm)
print(mn)


import os
import sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7
from collections import Counter
from math import inf

def main():
	(n, I) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	k = pow(2, int(I * 8 / n))
	c = Counter(arr)
	lst = [arr[0]]
	for i in range(1, n):
		if arr[i] != arr[i - 1]:
			lst.append(arr[i])
	ans = inf
	z = n
	n = len(lst)
	l = 0
	r = k - 1
	if k >= n:
		print(0)
		exit()
	sm = 0
	for i in range(k - 1):
		sm += c[lst[i]]
	while r < n:
		sm += c[lst[r]]
		ans = min(ans, z - sm)
		sm -= c[lst[l]]
		l += 1
		r += 1
	if ans == inf:
		print(0)
	else:
		print(ans)

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
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')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


(n, m) = map(int, input().split())
a = sorted(map(int, input().split()))
b = [0]
a += [1 << 30]
for i in range(n):
	if a[i] < a[i + 1]:
		b += [i + 1]
print(n - max((y - x for (x, y) in zip(b, b[1 << 8 * m // n:])), default=n))


from itertools import groupby

def solve():
	(n, disk) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	k = int(disk * 8 / n)
	dist = 1 << k
	counts = [len(list(group)) for (key, group) in groupby(sorted(a))]
	cur_changes = sum(counts[dist:])
	ans = cur_changes
	for i in range(0, len(counts) - dist):
		cur_changes += counts[i]
		cur_changes -= counts[i + dist]
		ans = min(ans, cur_changes)
	print(ans)
solve()


import sys, heapq, math
from collections import deque, defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
DBG = True
R = 10 ** 9 + 7

def ddprint(x):
	if DBG:
		print(x)
(n, i) = inm()
a = inl()
a.sort()
sa = list(set(a))
m = len(sa)
k = 8 * i // n
kk = 2 ** k
if kk >= m:
	print(0)
	exit()
h = {}
for x in a:
	if x in h:
		h[x] += 1
	else:
		h[x] = 1
b = []
prev = -1
for x in a:
	if x != prev:
		b.append(h[x])
	prev = x
accb = [0] * (m + 1)
for j in range(m):
	accb[j] = accb[j - 1] + b[j]
mx = 0
for j in range(m - kk):
	z = accb[j + kk - 1] - accb[j - 1]
	if z > mx:
		mx = z
print(accb[m - 1] - mx)


import sys
input = sys.stdin.readline
import collections
(n, I) = map(int, input().split())
A = [int(i) for i in input().split()]

def f(x):
	if x == 0:
		return 0
	else:
		return (x - 1).bit_length()

def check(y):
	return f(y) * n <= 8 * I
(l, r) = (1, 10 ** 9 + 1)
while r - l > 1:
	if check((l + r) // 2):
		l = (l + r) // 2
	else:
		r = (l + r) // 2
k = l
AA = sorted(collections.Counter(A).items(), key=lambda x: x[0])
nn = len(AA)
if k >= nn:
	print(0)
else:
	ans = 0
	tot = 0
	for i in range(k):
		tot += AA[i][1]
		ans = tot
	for i in range(k, nn):
		tot += AA[i][1]
		tot -= AA[i - k][1]
		ans = max(ans, tot)
	print(n - ans)


import sys
from math import log2
import bisect
import heapq
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

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 list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
(n, k) = Ri()
a = Ri()
s = set(a)
a.sort()
dist = len(s)
has = ceil(log2(dist))
required = k * 8 // n
if required >= has:
	print(0)
else:
	required = 2 ** required
	dic = {}
	for i in a:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	arr = [i for i in dic]
	pre = [0] * (len(arr) + 1)
	for i in range(len(arr)):
		pre[i + 1] = pre[i] + dic[arr[i]]
	summ = 0
	for i in dic:
		summ += dic[i]
	minn = INF
	for i in range(required - 1, len(arr)):
		minn = min(minn, summ - (pre[i + 1] - pre[i + 1 - required]))
	print(minn)


import sys
(n, I) = map(int, input().split())
a = list(map(int, input().split()))
b = a
b.sort()
c = []
d = []
for i in range(n):
	if i == 0:
		c.append(b[i])
		d.append(1)
	elif b[i] != b[i - 1]:
		c.append(b[i])
		d.append(1)
	else:
		d[len(d) - 1] += 1
K = len(c)
if K <= 2 ** (I * 8 // n):
	print(0)
else:
	epszilon = K - 2 ** (I * 8 // n)
	if epszilon != int(epszilon):
		epszilon = int(epszilon) + 1
	F = 0
	for i in range(epszilon):
		F += d[i]
	MIN = F
	for i in range(epszilon):
		F = F - d[epszilon - 1 - i] + d[len(d) - 1 - i]
		if F < MIN:
			MIN = F
	print(MIN)


from collections import Counter
(N, I) = map(int, input().split())
counter = Counter(list(map(int, input().split())))
a = sorted(counter.keys())
bits = I * 8 // N
if bits >= 30 or 2 ** bits >= len(a):
	print(0)
	exit()
sound_range = 2 ** bits
r = 0
acc = 0
for i in range(sound_range):
	acc += counter[a[r]]
	r += 1
ans = acc
for (l, r) in zip(range(len(a)), range(r, len(a))):
	acc += counter[a[r]] - counter[a[l]]
	if acc > ans:
		ans = acc
print(N - ans)


import sys
input = sys.stdin.readline
(n, I) = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
bits = I * 8
bps = bits // n
drange = 2 ** bps - 1
a.sort()
a_comp = []
itr = 0
for (i, item) in enumerate(a):
	if i == 0:
		prev = item
		a_comp.append(itr)
		continue
	if item == prev:
		a_comp.append(itr)
	else:
		itr += 1
		prev = item
		a_comp.append(itr)
a = a_comp
l = 0
r = 0
ans = 0
while r < n:
	if a[r] - a[l] <= drange:
		r += 1
		ans = max(ans, r - l)
	else:
		l += 1
print(n - ans)


import sys
import math
input = sys.stdin.readline
(n, I) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
cur = [1]
for i in range(1, n):
	if arr[i] == arr[i - 1]:
		cur[-1] += 1
	else:
		cur.append(1)
b = 2 ** (8 * I // n)
pre = [0, cur[0]]
for i in range(1, len(cur)):
	pre.append(cur[i] + pre[-1])
maxx = 0
for i in range(b, len(pre)):
	if pre[i] - pre[i - b] > maxx:
		maxx = pre[i] - pre[i - b]
if b >= len(pre):
	print(0)
else:
	print(n - maxx)


(n, i) = map(int, input().split())
lst = list(map(int, input().split()))
i *= 8
k = i // n
imax = 2 ** k
idict = {}
for i in lst:
	if idict.get(i) == None:
		idict[i] = 1
	else:
		idict[i] += 1
lst = sorted(idict.keys())
isum = 0
imin = None
l = 0
q = 0
r = 0
while r < len(lst):
	isum += 1
	q += idict[lst[r]]
	r += 1
	if isum > imax or r == len(lst):
		copyisum = q - idict[lst[r - 1]]
		if r == len(lst) and isum <= imax:
			copyisum += idict[lst[r - 1]]
		shakal = n - copyisum
		if imin == None or imin > shakal:
			imin = shakal
	while isum > imax:
		isum -= 1
		q -= idict[lst[l]]
		l += 1
print(imin)


(n, m) = map(int, input().split())
a = sorted([int(i) for i in input().split()])
k = 1 << m * 8 // n
(l, r) = (0, 1)
ans = n
cnt = k - 1
while r < n:
	if a[r - 1] == a[r] or cnt > 0:
		if a[r - 1] != a[r]:
			cnt -= 1
		r += 1
	else:
		ans = min(ans, n - r + l)
		l += 1
		if a[l] != a[l - 1]:
			cnt = 1
ans = min(ans, n - r + l)
print(ans)


from bisect import bisect_right, bisect_left
from collections import Counter
(N, I) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
K = 2 ** (I * 8 // N)
B = list(Counter(A).keys())
bb = len(B)
ans = N
for (i, l) in enumerate(A):
	b = bisect_left(B, l)
	j = bisect_right(A, B[min(b + K - 1, bb - 1)])
	ans = min(N - (j - i), ans)
print(ans)


import sys
(n, I) = [int(i) for i in input().split()]
num = 1 << 8 * I // n
data = [int(i) for i in input().split()]
dic = {}
for d in data:
	if d in dic:
		dic[d] += 1
	else:
		dic[d] = 1
if 8 * I < n:
	print(n - max(dic.values()))
	sys.exit()
vals = list(dic.keys())
vals.sort()
am = len(vals)
if am <= num:
	print(0)
	sys.exit()
sumto = [dic[vals[0]]]
for i in range(1, am):
	sumto.append(sumto[-1] + dic[vals[i]])
kept = sumto[num - 1]
for i in range(am - num):
	kept2 = sumto[i + num] - sumto[i]
	if kept2 > kept:
		kept = kept2
print(n - kept)


import math

def main():
	(n, i) = map(int, input().split())
	max_bits = 8 * i // n
	dist_values = 2 ** max_bits
	files = list(map(int, input().split()))
	files.sort()
	dist_files = []
	curr = files[0]
	count = 0
	for i in files:
		if i == curr:
			count += 1
		else:
			dist_files.append(count)
			curr = i
			count = 1
	dist_files.append(count)
	dp = []
	for i in dist_files:
		if not dp:
			dp.append(i)
		else:
			dp.append(dp[-1] + i)
	min_val = float('inf')
	for i in range(len(dp)):
		change = 0
		if i > 0:
			change += dp[i - 1]
		if i + dist_values - 1 < len(dp):
			change += dp[-1] - dp[i + dist_values - 1]
		min_val = min(min_val, change)
	print(min_val)
main()


(n, I) = map(int, input().split())
a = list(map(int, input().split()))
k = I * 8 // n
K = 2 ** k
a.sort()
A = [1]
j = 0
for i in range(1, n):
	if a[i] == a[i - 1]:
		A[j] += 1
	else:
		A.append(1)
		j += 1
c = len(A) - K
s1 = sum(A[:c])
s2 = 0
if c <= 0:
	ans = 0
else:
	ans = 10 ** 9 + 7
	for i in range(c + 1):
		ans = min(ans, s1 + s2)
		s1 -= A[c - 1 - i]
		s2 += A[len(A) - 1 - i]
print(ans)


def mp():
	return map(int, input().split())
(n, I) = mp()
a = sorted(list(mp()))
k = 2 ** (I * 8 // n)
cnt = [[a[0], 1]]
for i in range(1, n):
	if cnt[-1][0] == a[i]:
		cnt[-1][1] += 1
	else:
		cnt.append([a[i], 1])
N = n
n = len(cnt)
a = [i[1] for i in cnt]
s = sum(a[:k])
ans = s
for i in range(k, n):
	s -= a[i - k]
	s += a[i]
	ans = max(ans, s)
print(sum(a) - ans)


import math
l = [int(i) for i in input().split(' ')]
n = l[0]
bt = l[1]
ln = sorted([int(i) for i in input().split(' ')])
K = 1
dists = [1]
for i in range(1, len(ln)):
	if ln[i] != ln[i - 1]:
		K += 1
		dists.append(1)
	else:
		dists[-1] += 1
rdists = dists[:]
ldists = dists[::-1]
rd = [0]
for i in rdists:
	rd.append(rd[-1] + i)
ld = [0]
for i in ldists:
	ld.append(ld[-1] + i)
minVal = math.floor(2 ** math.floor(bt * 8 / n))
dels = 0
inds = 0
minVal = K - minVal
m = 10000000000
sm = m
i = minVal
j = 0
while i >= 0:
	m = min(m, rd[i] + ld[j])
	i -= 1
	j += 1
if m == sm:
	m = 0
print(m)


import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def main():
	(n, I) = map(int, input().split())
	A = list(map(int, input().split()))
	table = [0] * 21
	table[0] = 1
	for i in range(1, 21):
		table[i] = table[i - 1] * 2
	import bisect

	def is_ok(K):
		k = bisect.bisect_left(table, K)
		if n * k <= 8 * I:
			return True
		else:
			return False
	ok = 1
	ng = len(set(A)) + 1
	while ok + 1 < ng:
		c = (ok + ng) // 2
		if is_ok(c):
			ok = c
		else:
			ng = c
	K = ok
	from collections import Counter
	C = Counter(A)
	if len(C) <= K:
		print(0)
		exit()
	C = list(C.items())
	C.sort(key=lambda x: x[0])
	S = []
	for (k, v) in C:
		S.append(v)
	T = list(reversed(S))
	from itertools import accumulate
	CS = [0] + S
	CT = [0] + T
	CS = list(accumulate(CS))
	CT = list(accumulate(CT))
	p = len(C) - K
	ans = 5 * 10 ** 5
	for x in range(0, p + 1):
		y = p - x
		ans = min(ans, CS[x] + CT[y])
	print(ans)
main()


(n, I) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
k = 2 ** (I * 8 // n)
b = [0] * len(set(a))
be = a[0]
i = 0
t = 0
ma = 0
if k > len(b):
	print(0)
else:
	for x in a:
		if x != be:
			t += b[i]
			if i - k >= 0:
				t -= b[i - k]
			ma = max(ma, t)
			i += 1
			b[i] += 1
			be = x
		else:
			b[i] += 1
	if b[i] > 0:
		t += b[i]
		if i - k >= 0:
			t -= b[i - k]
		ma = max(ma, t)
	print(n - ma)