#include <bits/stdc++.h>
using namespace std;
const int L = 29;
int pw[29];
void prec() {
  pw[0] = 1;
  for (int i = 1; i < L; ++i) pw[i] = pw[i - 1] * 2;
}
int get_log(int a) {
  int t = log2(a);
  while (pw[t] < a) t++;
  return t;
}
map<int, int> ch;
void add(int v) { ch[v]++; }
void err(int v) {
  ch[v]--;
  if (ch[v] == 0) {
    ch.erase(v);
  }
}
void smart() {
  int n, I;
  cin >> n >> I;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int l = 0, r = n + 1;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (get_log(mid) * n > I * 8) {
      r = mid;
    } else {
      l = mid;
    }
  }
  int can = l;
  int res = 1e9;
  for (int r = 0, l = 0; r < n; ++r) {
    add(a[r]);
    while (ch.size() > can) {
      err(a[l++]);
    }
    res = min(res, l + n - r - 1);
  }
  cout << res << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  prec();
  smart();
  return 0;
}
