#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
const int MAX = 4e5 + 10;
int a[MAX];
vector<int> v;
int n, I;
int possible(int q) {
  int k = 0;
  int r = 1;
  while (r < q) {
    r *= 2;
    k++;
  }
  if (n * k <= 8 * I) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> I;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int count = 1;
  for (int i = 0; i < n; i++) {
    if (i == n - 1 || a[i] != a[i + 1]) {
      v.push_back(count);
      count = 1;
    } else
      count++;
  }
  int len = v.size();
  int high = len;
  int low = 1;
  if (possible(len)) {
    cout << "0" << endl;
    return 0;
  }
  while (possible(low + 1)) {
    int cen = (high + low + 1) / 2;
    if (possible(cen))
      low = cen;
    else
      high = cen;
  }
  int l = len - low;
  int r = len;
  int sum = 0;
  for (int i = 0; i < l; i++) {
    sum += v[i];
  }
  int res = sum;
  int q = l;
  for (int i = 0; i < q; i++) {
    l--;
    r--;
    sum -= v[l];
    sum += v[r];
    res = min(res, sum);
  }
  cout << res << endl;
}
