#include <bits/stdc++.h>
using namespace std;
vector<long long> s;
long long num[1000000], ans[1000000];
int main() {
  long long n, I;
  while (cin >> n >> I) {
    memset(num, 0, sizeof(num));
    memset(ans, 0, sizeof(ans));
    s.clear();
    for (int i = 0; i < n; i++) {
      cin >> num[i];
      s.push_back(num[i]);
    }
    if (I * 8 / n > 30)
      cout << "0" << endl;
    else {
      sort(num, num + n);
      sort(s.begin(), s.end());
      s.erase(unique(s.begin(), s.end()), s.end());
      long long k = ceil(log2(s.size()));
      if (I * 8 >= n * k) {
        cout << "0" << endl;
      } else {
        int tot = 1, r = 0;
        for (int i = 0; i < n; i++) {
          while (num[i] == num[i + r]) {
            r++;
          }
          ans[tot++] = r;
          i += r - 1;
          r = 0;
        }
        for (int i = 1; i <= tot; i++) {
          ans[i] += ans[i - 1];
        }
        long long oo = -1;
        long long p = pow(2, (I * 8) / n);
        for (long long i = 0; i + p <= tot; i++) {
          oo = max(oo, ans[i + p] - ans[i]);
        }
        cout << n - oo << endl;
      }
    }
  }
  return 0;
}
