#include <bits/stdc++.h>
using namespace std;
long long in[400001];
int n, siz;
int cnt[400001];
long long sum[400001];
int ptr = 0;
int get(int l, int r) {
  if (l < 0) l = 0;
  if (r >= ptr) r = ptr - 1;
  if (l == 0) {
    return sum[r];
  } else {
    return sum[r] - sum[l - 1];
  }
}
int main() {
  cin >> n >> siz;
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  long long res = pow(2, (long long)siz * (long long)8 / n);
  sort(in, in + n);
  cnt[0]++;
  for (int i = 1; i < n; i++) {
    if (in[i] != in[i - 1]) {
      ptr++;
    }
    cnt[ptr]++;
  }
  ptr++;
  int bit = 0;
  int safe_ptr = ptr;
  while (safe_ptr > 0) {
    bit++;
    safe_ptr /= 2;
  }
  if ((long long)bit * n < siz * 8) {
    cout << 0;
    return 0;
  }
  sum[0] = cnt[0];
  for (int i = 0; i < ptr; i++) {
    sum[i] = sum[i - 1] + cnt[i];
  }
  int best = 0;
  for (int i = 1; i < ptr - res + 1; i++) {
    if (get(i, i + res - 1) > get(best, best + res - 1)) {
      best = i;
    }
  }
  cout << sum[ptr - 1] - get(best, best + res - 1);
  return 0;
}
