#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a, firstPlace, distinct;
  int x, n;
  int space;
  cin >> n >> space;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    a.push_back(x);
  }
  distinct.resize(n);
  space *= 8;
  int reqd = space / n;
  if (reqd > 30 or n <= (1 << reqd)) {
    cout << 0 << '\n';
    return 0;
  }
  int shouldBe = 1 << reqd;
  sort(a.begin(), a.end());
  distinct[0] = 1;
  for (int i = 1; i < n; ++i) {
    distinct[i] = distinct[i - 1];
    if (a[i] != a[i - 1]) distinct[i]++;
  }
  int r = 0, maxi = 0;
  for (int l = 0; l < n; ++l) {
    int curr = distinct[r] - distinct[l] + 1;
    while (r < n and curr <= shouldBe) {
      r++;
      curr = distinct[r] - distinct[l] + 1;
    }
    maxi = max(maxi, r - l);
  }
  cout << n - maxi << '\n';
  return 0;
}
