#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 10;
int a[maxn], b[maxn], num[maxn], sum[maxn], n, m;
int main() {
  scanf("%d%d", &n, &m);
  m = m * 8;
  int k = m / n;
  int tmp = 1;
  for (int i = 1; i <= k; i++) tmp *= 2;
  k = tmp;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  int len = unique(b + 1, b + 1 + n) - b - 1;
  if (len == 1 || k >= len) {
    cout << 0;
    return 0;
  }
  if (ceil(log(len * 1.0) / log(2.0)) * n <= m) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    int t = lower_bound(b + 1, b + 1 + len, a[i]) - b;
    num[t]++;
  }
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + num[i];
  }
  int ans = maxn * 2;
  for (int i = 1; i + k - 1 <= len; i++) {
    ans = min(ans, n - (sum[i + k - 1] - sum[i - 1]));
  }
  cout << ans;
}
