#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int MAXN = 20010;
const int INF = 0x3f3f3f3f;
const double eps = 0.0000001;
const long long mod = 998244353;
int n, m, x, y, k, cnt;
int a[N], t[N], b[N], vis[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  scanf("%d%d", &n, &m);
  int ps = 8 * m / n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    t[i] = a[i];
  }
  if (ps >= 25) {
    printf("0\n");
    return 0;
  } else {
    cnt = 1;
    for (int i = 1; i <= ps; i++) cnt *= 2;
    if (cnt >= n) {
      printf("0\n");
      return 0;
    }
  }
  sort(t + 1, t + n + 1);
  x = unique(t + 1, t + 1 + n) - t - 1;
  for (int i = 1; i <= n; i++) b[i] = lower_bound(t + 1, t + 1 + x, a[i]) - t;
  for (int i = 1; i <= n; i++) {
    vis[b[i]]++;
  }
  if (cnt >= x) {
    printf("0\n");
    return 0;
  }
  int sum = 0, pp = 0;
  for (int i = 1; i <= cnt; i++) {
    sum += vis[i];
  }
  pp = max(pp, sum);
  for (int i = 2; i <= x - cnt + 1; i++) {
    sum -= vis[i - 1];
    sum += vis[i + cnt - 1];
    pp = max(pp, sum);
  }
  printf("%d\n", n - pp);
}
