#include <bits/stdc++.h>
using namespace std;
map<int, int> all;
int con[400005];
int Pow[35];
int main() {
  int N, M, K, now = 0, t = 0, big = 0, i;
  scanf("%d %d", &N, &M);
  M *= 8;
  M /= N;
  Pow[0] = 1;
  for (i = 1; i <= 30; i++) Pow[i] = Pow[i - 1] * 2;
  if (M >= 30)
    printf("0\n");
  else {
    for (i = 0; i < N; i++) {
      scanf("%d", &t);
      all[t]++;
    }
    K = 0;
    for (auto j : all) {
      con[K] = j.second;
      K++;
    }
    t = 0;
    for (i = 0; i < Pow[M] && i < K; i++) {
      t += con[i];
    }
    big = t;
    for (i = Pow[M]; i < K; i++) {
      t += con[i];
      t -= con[i - Pow[M]];
      big = max(big, t);
    }
    printf("%d\n", N - big);
  }
  return 0;
}
