#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
int n, I, k, a[N], b[N], B, t[N], ans;
int main() {
  scanf("%d%d", &n, &I);
  I <<= 3;
  k = I / n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];
  sort(b + 1, b + n + 1);
  B = unique(b + 1, b + n + 1) - (b + 1);
  if (k > 30 || (1 << k) >= B) return puts("0"), 0;
  for (int i = 1; i <= n; i++)
    a[i] = lower_bound(b + 1, b + B + 1, a[i]) - b, t[a[i]]++;
  k = 1 << k;
  ans = n;
  for (int i = 1; i <= B; i++) t[i] += t[i - 1];
  for (int i = k; i <= B; i++) ans = min(ans, n - t[i] + t[i - k]);
  return printf("%d\n", ans), 0;
}
