#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 10;
const int inf = 1e9 + 10;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int p = 29;
void solve() {
  int n, l;
  cin >> n >> l;
  l *= 8;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = n;
  int r = 0, uniq = 0;
  map<int, int> mp;
  int sz = 0;
  for (int i = 0; i <= 30; i++) {
    if (i * n <= l) {
      sz = (1 << i);
    }
  }
  for (int q = 0; q < n; q++) {
    while (r < n && uniq + (mp[a[r]] == 0) <= sz) {
      uniq += (mp[a[r]] == 0);
      mp[a[r]]++;
      r++;
    }
    ans = min(ans, q + n - r);
    uniq -= (mp[a[q]] == 1);
    mp[a[q]]--;
  }
  cout << ans << "\n";
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int col_test;
  col_test = 1;
  while (col_test--) {
    solve();
  }
  return 0;
}
