#include <bits/stdc++.h>
const double eps = 0.0000001;
using namespace std;
inline int sgn(double x) { return (x > eps) - (x < -eps); }
static char buf[100000], *pa = buf, *pd = buf;
inline long long read() {
  register long long x(0), f(1);
  register char c(
      pa == pd && (pd = (pa = buf) + fread(buf, 1, 100000, stdin), pa == pd)
          ? EOF
          : *pa++);
  while (c > '9' || c < '0')
    f = c == '-' ? -1 : 1,
    c = pa == pd && (pd = (pa = buf) + fread(buf, 1, 100000, stdin), pa == pd)
            ? EOF
            : *pa++;
  while (c >= '0' && c <= '9')
    x = x * 10 + c - 48,
    c = pa == pd && (pd = (pa = buf) + fread(buf, 1, 100000, stdin), pa == pd)
            ? EOF
            : *pa++;
  return f * x;
}
long long ans[(long long)1e6 + 5];
long long Qz[(long long)1e6 + 5];
map<long long, long long> sum;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> ans[i];
    sum[ans[i]]++;
  }
  sort(ans + 1, ans + n + 1);
  long long num = unique(ans + 1, ans + n + 1) - ans - 1;
  for (int i = 1; i <= num; ++i) {
    Qz[i] = Qz[i - 1] + sum[ans[i]];
  }
  long long bit = 8 * m;
  bit = (bit * 1.0 / n);
  if ((1 << bit) >= num || bit >= 20) {
    cout << 0 << endl;
    return 0;
  }
  long long i = 1, j = num;
  long long Sum = num - (1 << bit);
  j = num;
  long long MAX = -1e10;
  for (int i = 1, j = num - Sum; j <= num; i++, j++) {
    MAX = max(MAX, Qz[j] - Qz[i - 1]);
  }
  cout << Qz[num] - MAX;
}
