#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 20;
long long a[maxn];
long long b[maxn];
long long qpow(int a, int b) {
  long long ans = 1, de = a;
  while (b != 0) {
    if (b & 1) ans = ans * de;
    b = b / 2;
    de = de * de;
  }
  return ans;
}
int main() {
  long long n, I, i;
  cin >> n >> I;
  long long k;
  I = 8 * I / n;
  if (I > 30) I = 30;
  k = qpow(2, I);
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  a[0] = -1;
  b[0] = 0;
  for (i = 1; i <= n; i++) {
    if (a[i] == a[i - 1]) {
      b[i] = b[i - 1];
    } else {
      b[i] = b[i - 1] + 1;
    }
  }
  if (k > b[n]) {
    cout << 0 << endl;
    return 0;
  }
  long long mn = n, l, r, ans;
  for (l = 1, r = 1; r <= n; r++) {
    ans = b[r];
    if (ans < k) continue;
    while (ans - b[l] >= k) ans = ans - b[l++];
    if (ans == k) {
      mn = min(mn, n - (r - l + 1));
    }
  }
  cout << mn << endl;
  return 0;
}
