#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 1e6 + 5, M = 1e4 + 5;
int a[N], powe[N];
int main() {
  long long n;
  long long I;
  scanf("%lld%lld", &n, &I);
  I *= 8ll;
  long long kam = I / n;
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    ++mp[x];
  }
  vector<int> v;
  for (auto i : mp) v.push_back(i.second);
  for (int i = 1; i < N; ++i) powe[i] = powe[i >> 1] + 1;
  long long ans = 0, mn = 1e18;
  for (int i = 0, j = 0; i < v.size(); ++i) {
    while (j < v.size() && n * powe[j - i] <= I) {
      ans += v[j++];
      mn = min(mn, n - ans);
    }
    ans -= v[i];
  }
  printf("%lld\n", mn);
  return 0;
}
