#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int one = 1;
  if (!y)
    return one;
  else if (y == 1)
    return x;
  else {
    long long int y1 = power(x, y >> 1);
    long long int y2 = y1 * y1;
    if (y & 1)
      return x * y2;
    else
      return y2;
  }
}
bool comp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    return a.second > b.second;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, mx;
  cin >> n >> mx;
  long long int a[n];
  map<long long int, long long int> occ;
  for (int i = 0; i < n; i++) cin >> a[i], occ[a[i]]++;
  long long int allow = 8 * mx;
  allow /= n;
  if (allow > 20) {
    cout << 0;
    return 0;
  }
  long long int dis = power(2, allow);
  vector<pair<int, int> > give;
  for (auto v : occ) give.push_back(make_pair(v.first, v.second));
  long long int n1 = give.size();
  sort(give.begin(), give.end(), comp);
  long long int ans = INT_MAX;
  long long int presum[n1];
  presum[0] = give[0].second;
  for (int i = 1; i < n1; i++) presum[i] = presum[i - 1] + give[i].second;
  if (n1 <= dis) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i <= n1 - dis; i++) {
    int rem = 0;
    if (i == 0)
      rem = presum[i + dis - 1];
    else
      rem = presum[i + dis - 1] - presum[i - 1];
    if (n - rem < ans) ans = n - rem;
  }
  cout << ans;
}
