#include <bits/stdc++.h>
using namespace std;
const int maxn = 400010;
int n, k, a[maxn], b[maxn], cnt = 1, ans;
int main() {
  cin >> n >> k;
  k = 8 * k / n;
  k = min(30, k);
  k = 1 << k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  b[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] == a[i - 1])
      b[cnt]++;
    else
      b[++cnt]++;
  }
  for (int i = 1; i <= cnt; i++) {
    b[i] += b[i - 1];
  }
  k = min(cnt, k);
  for (int i = k; i <= cnt; i++) ans = max(ans, b[i] - b[i - k]);
  cout << n - ans << endl;
}
