#include <bits/stdc++.h>
const int MAXN = 4e5 + 5, MAXM = 1e6 + 5, MOD = 1e9 + 7, INF = 0x3f3f3f3f,
          N = 2e5;
const long long INFL = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
using namespace std;
int n, I, a[MAXN], b[MAXN], sum[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> I;
  for (int i = 1; i <= n; i++) cin >> a[i], b[i] = a[i];
  sort(b + 1, b + 1 + n);
  int len = unique(b + 1, b + 1 + n) - b - 1;
  int up = 1;
  for (int i = 1; i <= I * 8 / n; i++) {
    up <<= 1;
    if (up >= len) break;
  }
  up = min(up, len);
  for (int i = 1; i <= n; i++) a[i] = lower_bound(b + 1, b + 1 + len, a[i]) - b;
  for (int i = 1; i <= n; i++) sum[a[i]]++;
  for (int i = 1; i <= len; i++) sum[i] += sum[i - 1];
  int ans = INF;
  for (int i = 1; i <= len; i++) {
    ans = min(ans, n - sum[min(len, i + up - 1)] + sum[i - 1]);
  }
  cout << ans << '\n';
  return 0;
}
