#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, I;
  scanf("%d %d", &N, &I);
  int bits = I * 8 / N;
  int max_distinct = bits > 30 ? N + 1 : 1 << bits;
  vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &v[i]);
  }
  sort(v.begin(), v.end());
  vector<int> freqs;
  int count = 0;
  int prev = -1;
  for (int i = 0; i < N; ++i) {
    if (v[i] != prev) {
      if (count > 0) freqs.push_back(count);
      prev = v[i];
      count = 1;
    } else {
      count++;
    }
  }
  if (count > 0) {
    freqs.push_back(count);
  }
  vector<int> prefix;
  for (int i = 0; i < freqs.size(); ++i) {
    prefix.push_back(freqs[i] + (i == 0 ? 0 : prefix[i - 1]));
  }
  int min_delete = N;
  for (int r = 0; r < prefix.size(); ++r) {
    int l = r - max_distinct;
    int n_include = prefix[r] - (l >= 0 ? prefix[l] : 0);
    int n_remove = N - n_include;
    min_delete = min(min_delete, n_remove);
  }
  printf("%d\n", min_delete);
  return 0;
}
