#include <bits/stdc++.h>
using namespace std;
long long Log(long long x) {
  if (x < 1) return 0;
  int r = 0;
  while (x > 0) {
    x /= 2;
    r++;
  }
  return r - 1;
}
int solve(map<long long, int> M, long long n, long long byte) {
  int bit = byte * 8;
  vector<pair<int, int> > vec;
  for (auto it = M.begin(); it != M.end(); it++) {
    vec.push_back(make_pair(it->first, it->second));
  }
  queue<pair<int, int> > Q;
  int ans = 1 << 30, cnt = 0;
  long long sum = 0;
  for (auto it = M.begin(); it != M.end(); it++) {
    Q.push(make_pair(it->first, it->second));
    cnt++;
    sum += it->second;
    while ((int)(ceil(log2(cnt))) * n > bit) {
      pair<int, int> r = Q.front();
      Q.pop();
      sum -= r.second;
      cnt--;
    }
    ans = min((long long)ans, n - sum);
  }
  return ans;
}
int main() {
  long long n, byte;
  cin >> n >> byte;
  long long bit = byte * 8LL;
  long long ara[n + 5];
  map<long long, int> M;
  map<long long, int>::iterator it;
  vector<int> vs;
  for (int i = 0; i < n; i++) {
    cin >> ara[i];
    vs.push_back(ara[i]);
    M[ara[i]]++;
  }
  vector<int> vec;
  for (it = M.begin(); it != M.end(); it++) vec.push_back(it->second);
  int len = vec.size();
  int ans = 0;
  int element = len;
  int lf = 0, ri = len - 1;
  for (int i = 0; i < len; i++) {
    element = (ri - lf + 1);
    int r = ceil((double)log2(element));
    if ((r * n) <= bit) {
      break;
    }
    if (vec[lf] < vec[ri]) {
      ans += vec[lf];
      lf++;
    } else {
      ans += vec[ri];
      ri--;
    }
  }
  int rrr = solve(M, n, byte);
  cout << rrr << endl;
  return 0;
}
