#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') {
      f = -1;
    }
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int n, I;
int ans = 0X7fffffff;
int b[N], a[N], cnt, num;
int main() {
  n = read(), I = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i + 1]) {
      num++;
      b[++cnt] = num;
      num = 0;
    } else
      num++;
  }
  int maxx = (8 * I / n);
  if (log2(cnt) <= maxx) {
    puts("0");
    return 0;
  }
  maxx = pow(2, maxx);
  for (int i = 1; i <= cnt + maxx; i++) {
    b[i] += b[i - 1];
  }
  for (int i = 1; i <= cnt; i++) {
    ans = min(ans, b[i] + b[cnt] - b[i + maxx]);
  }
  printf("%d", ans);
  return 0;
}
