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

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


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


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)


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


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)


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


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


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


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


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)


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


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)


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


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)


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


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


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)


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


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


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)


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