#include <bits/stdc++.h>
using namespace std;
long long MOD = int(1e9) + 7;
int debug = 1;
const int N = int(1e6) + 5;
using namespace std;
int a[N], b[N], s[N];
vector<int> every;
int get(int l, int r) {
  if (r > N - 1) r = N - 1;
  return s[r] - s[l - 1];
}
int main() {
  long long i, j, n, t, m;
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    every.push_back(a[i]);
  }
  sort(every.begin(), every.end());
  every.erase(unique(every.begin(), every.end()), every.end());
  ;
  for (i = 0; i < n; i++) {
    b[(lower_bound(every.begin(), every.end(), a[i]) - every.begin()) + 1]++;
  }
  for (i = 1; i < N; i++) s[i] = s[i - 1] + b[i];
  long long num_bits = 8 * m / n;
  if (num_bits >= 20) {
    cout << 0;
    return 0;
  }
  int maxrange = (1 << num_bits);
  int ans = n;
  for (i = 1; i <= n; i++) {
    ans = min(ans, (int)n - get(i, i + maxrange - 1));
  }
  cout << ans;
}
