#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
int n, cnt = 1;
long long ans, sum, a, I, l, k = 1;
struct node {
  int x;
  int num;
} qwq[N];
bool cmp(node a, node b) { return a.x < b.x; }
map<long long, int> mp;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> I;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (!mp[a]) {
      mp[a] = cnt++;
      qwq[mp[a]].x = a;
    }
    qwq[mp[a]].num++;
  }
  sort(qwq + 1, qwq + cnt, cmp);
  l = qwq[0].num;
  I *= 8;
  I /= n;
  while (I--) {
    k *= 2;
    if (k >= cnt) {
      cout << "0" << endl;
      return 0;
    }
  }
  if (k >= cnt - 1) {
    cout << "0" << endl;
    return 0;
  }
  for (int i = 1; i < cnt; ++i) {
    if (i < k)
      ans += qwq[i].num, sum = ans;
    else {
      sum += (qwq[i].num - qwq[i - k].num);
      ans = max(sum, ans);
    }
  }
  cout << n - ans << endl;
  return 0;
}
