#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, I;
  cin >> n >> I;
  I *= 8;
  vector<int> un;
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (!cnt.count(a)) {
      un.push_back(a);
    }
    cnt[a]++;
  }
  int ans = n;
  int m = un.size();
  if (ceil((long double)log2(m)) * n <= I) {
    cout << 0;
    return 0;
  }
  sort(un.begin(), un.end());
  int lo = 1, hi = m;
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    if (ceil((long double)log2(mid)) * n <= I) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  int suf[m + 1];
  memset(suf, 0, sizeof(suf));
  for (int i = m - 1; i >= 0; i--) {
    suf[i] = suf[i + 1] + cnt[un[i]];
  }
  int need = m - lo;
  int sum1 = 0;
  for (int i = -1; i < need; i++) {
    int newNeed = need - (i + 1);
    if (i != -1) sum1 += cnt[un[i]];
    int right = m - (newNeed);
    ans = min(ans, sum1 + suf[right]);
  }
  cout << ans;
  return 0;
}
