#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1e6;
long long a[N], b[N];
int main() {
  priority_queue<int, vector<int>, greater<int> > q;
  int n, I, i, len;
  long long k, x, ans;
  cin >> n >> I;
  I = min(8 * I / n, 20);
  k = pow(2, I);
  for (i = 1; i <= n; i++) {
    cin >> x;
    q.push(x);
  }
  len = 1;
  a[1] = q.top();
  b[1] = 1;
  q.pop();
  while (!q.empty()) {
    if (q.top() == a[len]) {
      b[len]++;
      q.pop();
    } else {
      a[++len] = q.top();
      q.pop();
      b[len] = 1;
    }
  }
  if (k >= len)
    cout << 0 << endl;
  else {
    for (i = 1; i <= len; i++) {
      b[i] += b[i - 1];
    }
    ans = inf;
    for (i = 1; i <= len; i++) {
      ans = min(ans, n - (b[i + k - 1] - b[i - 1]));
    }
    cout << ans << endl;
  }
  return 0;
}
