#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long inf = 1e9 + 7;
const double eps = 1e-7;
long long n, I;
long long f(long long k) {
  if (k == 1 || k == 0) return 0;
  double a = ((log(k)) / log(2));
  if (fabs(a - (long long)a) > eps) a = (long long)a + 1;
  double b = (n * a);
  b /= 8;
  if (fabs(b - (long long)b) > eps) b = (long long)b + 1;
  return b;
}
long long compression(long long a, vector<long long> &x) {
  return lower_bound(begin(x), end(x), a) - begin(x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> I;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<long long> v = a;
  sort(a.begin(), a.end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
  long long new_n = a.size();
  vector<long long> ans(new_n);
  for (long long i = 0; i < new_n; i++) {
    long long l = i, r = new_n - 1, mid = (l + r) / 2;
    while (r - l > 1) {
      if (f(mid - i + 1) <= I) {
        l = mid;
      } else {
        r = mid;
      }
      mid = (l + r) / 2;
    }
    if (f(r - i + 1) <= I)
      ans[i] = r;
    else
      ans[i] = l;
  }
  long long min = inf, id_min = 0;
  vector<long long> count(new_n);
  for (long long i = 0; i < n; i++) {
    count[compression(v[i], a)]++;
  }
  vector<long long> pref_cnt(new_n);
  pref_cnt[0] = count[0];
  for (long long i = 1; i < new_n; i++) {
    pref_cnt[i] = pref_cnt[i - 1] + count[i];
  }
  min = n - pref_cnt[ans[0]];
  for (long long i = 1; i < new_n; i++) {
    if (min > pref_cnt[i - 1] + n - pref_cnt[ans[i]])
      min = pref_cnt[i - 1] + n - pref_cnt[ans[i]];
  }
  cout << min;
}
