#include <bits/stdc++.h>
using namespace std;
const long long N = 4e5 + 10;
long long arr[N];
long long pre[N];
long long n, I;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> I;
  map<long long, long long> mp;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
    mp[arr[i]]++;
  }
  I *= 8;
  I /= n;
  if (I > 20) {
    cout << 0;
    return 0;
  }
  long long tot = mp.size();
  I = (1 << I);
  if (I >= tot) {
    cout << 0;
    return 0;
  }
  long long at = 0;
  for (auto i : mp) {
    at++;
    pre[at] = pre[at - 1] + i.second;
  }
  long long ans = INT_MAX, max_K = I;
  for (long long i = 1; i + max_K - 1 <= tot; i++) {
    ans = min(ans, n - (pre[i + max_K - 1] - pre[i - 1]));
  }
  cout << ans;
  return 0;
}
