#include <bits/stdc++.h>
using namespace std;
const int maxn = 500000;
int a[maxn], b[maxn];
pair<int, int> v[maxn];
int n, I;
signed main() {
  cin >> n >> I;
  for (int i = 0; i < n; i++) cin >> a[i];
  if (8 * I / n >= 30) {
    cout << 0;
    return 0;
  }
  sort(a, a + n);
  int p1 = 0, p2 = 0;
  int cr = 1;
  int mr = 0;
  while (n * mr <= 8 * I) ++mr;
  --mr;
  mr = (1 << mr);
  int ans = 0;
  while (p2 < n - 1) {
    ++p2;
    if (a[p2] != a[p2 - 1]) ++cr;
    if (cr > mr) {
      while (cr > mr) {
        ++p1;
        if (a[p1] != a[p1 - 1]) --cr;
      }
    }
    ans = max(ans, p2 - p1);
  }
  cout << n - ans - 1;
  return 0;
}
