#include <bits/stdc++.h>
using namespace std;
long long a[400005];
long long read() {
  long long A;
  bool K;
  char C;
  C = A = K = 0;
  while (C < '0' || C > '9') K |= C == '-', C = getchar();
  while (C > '/' && C < ':') A = (A << 3) + (A << 1) + (C ^ 48), C = getchar();
  return (K ? -A : A);
}
int main() {
  long long n, i, j, k, h, t, sum, mn;
  k = h = 1;
  sum = t = 0;
  n = read(), i = read();
  mn = n - 1;
  i = (i << 3) / n;
  for (j = 1; j <= i; j++) {
    k <<= 1;
    if (k >= n) putchar('0'), exit(0);
  }
  for (j = 1; j <= n; j++) a[j] = read();
  sort(a + 1, a + n + 1);
  a[0] = -1;
  while (t < n) {
    while (t < n && (sum < k || ((a[t + 1] == a[t]) && sum == k)))
      t++, sum += a[t] != a[t - 1];
    if (t > n) break;
    mn = (mn < h - 1 + n - t ? mn : h - 1 + n - t);
    while (h < t && a[h + 1] == a[h]) h++;
    h++;
    sum--;
  }
  cout << (mn < n - t + h - 1 ? mn : n - t + h - 1);
  return 0;
}
