#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int nega = 1;
  while (!isdigit(ch)) {
    if (ch == '-') nega = -1;
    ch = getchar();
  }
  int ans = 0;
  while (isdigit(ch)) {
    ans = ans * 10 + ch - 48;
    ch = getchar();
  }
  if (nega == -1) return -ans;
  return ans;
}
int a[400005];
int b[400005], cnt[400005];
int n, I;
int pre[400005 * 2];
int suf[400005 * 2];
int sum[400005 * 2];
signed main() {
  cin >> n >> I;
  for (int i = 1; i <= n; i++) a[i] = read(), b[i] = a[i];
  sort(b + 1, b + n + 1);
  int q = unique(b + 1, b + n + 1) - b - 1;
  for (int i = 1; i <= n; i++) {
    a[i] = lower_bound(b + 1, b + q + 1, a[i]) - b;
    cnt[a[i]]++;
  }
  int K = I * 8 / n;
  if (K >= 20) {
    cout << "0\n";
    return 0;
  }
  int len = 1, ans = n;
  for (int i = 1; i <= K; i++) len *= 2;
  if (len >= q) {
    cout << "0\n";
    return 0;
  }
  for (int i = 1; i <= q; i++) pre[i] = pre[i - 1] + cnt[i];
  for (int i = q; i >= 1; i--) suf[i] = suf[i + 1] + cnt[i];
  for (int i = 1; i <= q - len + 1; i++) {
    if (ans > suf[i + len] + pre[i - 1]) ans = suf[i + len] + pre[i - 1];
  }
  cout << ans << endl;
  return 0;
}
