#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a[400005];
pair<long long, long long> b[400005];
int sz;
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  m *= 8;
  m /= n;
  if (m > 35)
    m = (1ll << 32ll);
  else
    m = (1ll << m);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i)
    if (i == 1 || a[i] != a[i - 1])
      b[++sz] = {a[i], 1};
    else
      b[sz].second++;
  n = sz;
  for (int i = 1; i <= n; ++i) b[i].second += b[i - 1].second;
  long long ans = 1e18, cur;
  for (int i = 1; i <= n; ++i) {
    cur = b[i - 1].second;
    if (i + m - 1 <= n) cur += b[n].second - b[i + m - 1].second;
    ans = min(ans, cur);
  }
  cout << ans << '\n';
}
