#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4e5 + 5;
int n, b;
int a[MAXN];
void addNext(int& right) {
  if (right == n) return;
  right++;
  while (right < n && a[right] == a[right - 1]) right++;
}
void removeLeft(int& left, int& right) {
  left++;
  while (left < right && a[left] == a[left - 1]) left++;
}
int main() {
  scanf("%d%d", &n, &b);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  if (8 * b / n >= 20 || 1ll << (8 * b / n) >= n) {
    printf("0\n");
    return 0;
  }
  sort(a, a + n);
  long long k = 1ll << (8 * b / n);
  int right = 0;
  int left = 0;
  for (int i = 0; i < k; ++i) addNext(right);
  int sol = n - (right - left);
  while (right < n) {
    removeLeft(left, right);
    addNext(right);
    sol = min(sol, n - (right - left));
  }
  printf("%d\n", sol);
  return 0;
}
