#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int n;
int I;
const int N = 4e5 + 300;
int cnt[N];
bool check(int K) {
  int k = (int)ceil(log2(K));
  return (k * n <= I * 8);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  cin >> I;
  v.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  sort(v.begin() + 1, v.end());
  set<int> s;
  for (int i = 1; i <= n; i++) {
    if (!s.count(v[i])) {
      cnt[i]++;
    }
    s.insert(v[i]);
  }
  for (int i = 1; i <= n; i++) {
    cnt[i] += cnt[i - 1];
  }
  int ans = 1e9;
  for (int i = 1; i <= n; i++) {
    if (i == 1 || v[i - 1] != v[i]) {
      int l = i;
      int r = n;
      int cur = i;
      while (l <= r) {
        int mid = (l + r) / 2;
        int K = cnt[mid] - cnt[i - 1];
        if (check(K)) {
          cur = mid;
          l = mid + 1;
        } else {
          r = mid - 1;
        }
      }
      ans = min(ans, n - (cur - i + 1));
    }
  }
  cout << ans << "\n";
  return 0;
}
