#include <bits/stdc++.h>
using namespace std;
long long n, I, k = 1, K, arr[400005], now, t, l, r, has;
vector<long long> v;
int main() {
  cin >> n >> I;
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  sort(arr + 1, arr + n + 1);
  K = 8 * I / n;
  for (int i = 1; i <= K; i++) {
    k *= 2;
    if (k >= n) {
      cout << "0" << endl;
      return 0;
    }
  }
  t = 1;
  now = arr[1];
  for (long long i = 2; i <= n; i++) {
    if (arr[i] == now)
      t++;
    else {
      now = arr[i];
      v.push_back(t);
      t = 1;
    }
  }
  v.push_back(t);
  if (v.size() <= k) {
    cout << "0" << endl;
    return 0;
  }
  has = n;
  for (long long i = k; i < v.size(); i++) r += v[i];
  for (long long i = 0; i < v.size() - k; i++) {
    has = min(has, l + r);
    l += v[i];
    r -= v[i + k];
  }
  has = min(has, l + r);
  cout << has << endl;
}
