#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, i;
  cin >> n >> i;
  int s = 8 * i / n;
  if (s >= 19) return cout << 0, 0;
  int k = 1 << s;
  int a[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int cnt = 0;
  vector<int> vec;
  for (int i = 1; i <= n; i++) {
    cnt++;
    if (i == n || a[i] != a[i + 1]) vec.push_back(cnt), cnt = 0;
  }
  if (vec.size() <= k) return cout << 0, 0;
  int sum = 0;
  for (int i = 0; i < k; i++) sum += vec[i];
  int ans = n - sum;
  for (int i = k; i < vec.size(); i++) {
    sum += vec[i] - vec[i - k];
    ans = min(ans, n - sum);
  }
  cout << ans;
}
