#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  map<int, int> omap;
  int n, x, I;
  cin >> n >> I;
  map<int, int>::iterator itr = omap.begin();
  for (i = 0; i < n; i++) {
    cin >> x;
    itr = omap.find(x);
    if (itr == omap.end()) {
      omap.insert(pair<int, int>(x, 1));
    } else {
      itr->second = itr->second + 1;
    }
  }
  int K = omap.size();
  int k = (I * 8) / n;
  int kAllowed = pow(2, k);
  int need = K - kAllowed;
  if (need <= 0) {
    cout << 0;
    exit(0);
  }
  map<int, int>::iterator itr1 = omap.begin();
  map<int, int>::iterator itr2 = omap.end();
  itr2--;
  vector<int> ans1(need + 1, 0);
  vector<int> ans2(need + 1, 0);
  for (i = 1; i <= need; i++) {
    ans1[i] = ans1[i - 1] + itr1->second;
    itr1++;
  }
  for (i = 1; i <= need; i++) {
    ans2[i] = ans2[i - 1] + itr2->second;
    itr2--;
  }
  int ans = 0;
  int minimum = INT_MAX;
  for (i = 1; i <= need; i++) {
    ans = ans1[i] + ans2[need - i];
    if (ans < minimum) {
      minimum = ans;
    }
  }
  cout << minimum;
  return 0;
}
