#include <bits/stdc++.h>
using namespace std;
long long find_last_less(long long n, long long* array, int size) {
  long long l = 0;
  long long r = size - 1;
  while (r - l > 1) {
    long long m = (l + r) / 2;
    if (array[m] < n) {
      l = m;
    } else {
      r = m;
    }
  }
  if (array[r] < n) {
    l = r;
  }
  return l;
}
int main() {
  long long n, I;
  cin >> n >> I;
  I = I * 8 / n;
  if (I > 30) {
    I = 30;
  }
  long long num_of_uniq = (1 << I);
  long long array[n];
  long long num_of_different[n];
  for (auto& i : array) {
    cin >> i;
  }
  sort(array, array + n);
  num_of_different[0] = 1;
  for (int i = 1; i < n; ++i) {
    if (array[i] != array[i - 1]) {
      num_of_different[i] = num_of_different[i - 1] + 1;
    } else {
      num_of_different[i] = num_of_different[i - 1];
    }
  }
  long long max =
      find_last_less(num_of_different[0] + num_of_uniq, num_of_different, n) +
      1;
  for (long long i = 1; i < n; ++i) {
    if (find_last_less(num_of_different[i] + num_of_uniq, num_of_different, n) -
            i + 1 >
        max) {
      max = find_last_less(num_of_different[i] + num_of_uniq, num_of_different,
                           n) -
            i + 1;
    }
  }
  cout << n - max;
  return 0;
}
