#include <bits/stdc++.h>
using namespace std;
int a[400006];
vector<int> dis;
int main() {
  int i, j, m, n, c, x, l, y, t, bytes;
  cin >> n >> bytes;
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int total = 1;
  for (i = 1; i < n; i++) {
    while (i < n && a[i] == a[i - 1]) {
      total++;
      i++;
    }
    dis.push_back(total);
    total = 1;
  }
  if (a[n - 1] != a[n - 2]) dis.push_back(1);
  bytes *= 8;
  int bits = bytes / n;
  if (bits > 31) {
    cout << 0;
    return 0;
  }
  total = pow(2, bits);
  if (total >= dis.size()) {
    cout << 0;
    return 0;
  }
  int ans = 0;
  int temp = 0;
  for (i = 1; i < dis.size(); i++) {
    dis[i] += dis[i - 1];
  }
  ans = dis[total - 1];
  for (i = total; i < dis.size(); i++) {
    ans = max(ans, dis[i] - dis[i - total]);
  }
  cout << n - ans;
  return 0;
}
