#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4e5 + 5;
int n, I;
int a[MAXN], num[MAXN];
int read() {
  int s = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') s = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * s;
}
int main() {
  n = read(), I = read();
  int maxk = 8 * I / n, maxK = pow(2, maxk);
  if (maxk >= 20) {
    cout << "0\n";
    return 0;
  }
  for (int i = 1; i <= n; ++i) a[i] = read();
  sort(a + 1, a + n + 1);
  int cnt = 1;
  num[cnt] = 1;
  for (int i = 2; i <= n; ++i) {
    if (a[i] == a[i - 1])
      num[cnt]++;
    else
      num[++cnt] = num[cnt - 1] + 1;
  }
  if (cnt <= maxK) {
    cout << "0\n";
    return 0;
  }
  int max_con = -1;
  for (int i = maxK; i <= cnt; ++i) {
    int tmp = num[i] - num[i - maxK];
    max_con = max(max_con, tmp);
  }
  cout << n - max_con << endl;
}
