#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
long long int a[400005], pre[400005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  k *= 8;
  k /= n;
  if (k >= 20) {
    cout << 0 << endl;
    return 0;
  }
  map<int, int> ump;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ump[a[i]]++;
  }
  sort(a, a + n);
  vector<int> vv;
  vv.push_back(0);
  for (auto xx : ump) {
    vv.push_back(xx.second);
  }
  int nn = unique(a, a + n) - a;
  k = 1 << k;
  if (k >= nn) {
    cout << 0 << endl;
    return 0;
  }
  int ans = inf;
  for (int i = 1; i <= nn; i++) vv[i] += vv[i - 1];
  int tmp;
  for (int i = 1; i <= nn - k + 1; i++) {
    tmp = vv[i - 1] + vv[nn] - vv[i + k - 1];
    ans = min(tmp, ans);
  }
  cout << ans << endl;
}
