#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 4e5 + 10;
map<int, int> mp;
int a[MAX_N], I, n;
int fr[MAX_N], bk[MAX_N], sum_fr[MAX_N], sum_bk[MAX_N];
vector<int> v;
int log_2[MAX_N];
inline int want(int x) {
  int t = 0, now = 1;
  while (now < x) {
    now *= 2;
    t++;
  }
  return t;
}
int main() {
  for (int i = 1; i < MAX_N; i++) log_2[i] = want(i);
  scanf("%d%d", &n, &I);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) mp[a[i]]++;
  int t = 0;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    v.push_back(it->second);
  }
  t = v.size();
  for (int i = 0; i < v.size(); i++) {
    sum_fr[i] = v[i];
    sum_bk[i] = v[t - i - 1];
  }
  fr[0] = 0;
  bk[0] = 0;
  for (int i = 1; i <= t; i++) fr[i] = fr[i - 1] + sum_fr[i - 1];
  for (int i = 1; i <= t; i++) bk[i] = bk[i - 1] + sum_bk[i - 1];
  int org = t;
  I = 8 * I;
  if (log_2[org] * n <= I) {
    cout << 0 << endl;
    return 0;
  }
  int ed = t, ans = MAX_N;
  for (int i = 0; i <= t; i++) {
    while (true) {
      if (ed < 0) break;
      if (org - i - ed >= 1) {
        if (log_2[org - i - ed] * n > I) break;
      }
      ed--;
    }
    int now_ans = fr[i] + bk[ed + 1];
    ans = min(ans, now_ans);
  }
  cout << ans << endl;
  return 0;
}
