#include <bits/stdc++.h>
using namespace std;
const int N = 400005;
int a[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, s;
  cin >> n >> s;
  int max_diff = 1 << min(20, 8 * s / n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int l = 0, r = 0;
  int diff = 1;
  int best = n - 1;
  while (l < n - 1) {
    while (diff <= max_diff) {
      best = min(best, n - (r - l + 1));
      if (r == n - 1) {
        break;
      }
      if (a[r] != a[r + 1]) {
        diff++;
      }
      r++;
    }
    if (l < n - 1 && a[l] != a[l + 1]) {
      diff--;
    }
    l++;
  }
  cout << best << "\n";
}
