#include <bits/stdc++.h>
using namespace std;
template <class Read>
void in(Read &x) {
  x = 0;
  int f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    f |= (ch == '-');
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x = f ? -x : x;
  return;
}
int n, m, k, ans = 1 << 30, a[1000005], b[1000005], sum[1000005];
int check(int x, int y) {
  int x1 = sum[x - 1] - sum[0];
  int x2 = sum[k] - sum[y];
  int x3 = y - x + 1;
  x3 = ceil(log2(x3)) * n;
  if (x3 <= m * 8) return x1 + x2;
  return -1;
}
int main() {
  in(n);
  in(m);
  for (int i = 1; i <= n; i++) {
    in(a[i]);
    b[i] = a[i];
  }
  sort(a + 1, a + 1 + n);
  sort(b + 1, b + 1 + n);
  k = unique(b + 1, b + 1 + n) - b - 1;
  for (int i = 1; i <= n; i++) a[i] = lower_bound(b + 1, b + 1 + k, a[i]) - b;
  for (int i = 1; i <= n; i++) sum[a[i]]++;
  for (int i = 1; i <= k; i++) sum[i] += sum[i - 1];
  for (int i = 1; i <= k; i++) {
    int l = i;
    int r = k;
    int sum = 1 << 30;
    while (l <= r) {
      int mid = (l + r) / 2;
      int tot = check(i, mid);
      if (tot != -1) {
        sum = tot;
        l = mid + 1;
      } else
        r = mid - 1;
    }
    ans = min(ans, sum);
  }
  printf("%d\n", ans);
  return 0;
}
