#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, I, k, Kmax;
  cin >> n >> I;
  int arr[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    b[i] = arr[i];
  }
  sort(b, b + n);
  int distinct = 1;
  vector<int> freq;
  int count = 0;
  for (int i = 0; i < n; i++) {
    count++;
    if (i != n - 1 && b[i + 1] != b[i]) {
      distinct++;
      freq.push_back(count);
      count = 0;
    } else if (i == n - 1) {
      freq.push_back(count);
    }
  }
  k = 8 * I / n;
  if (k > 20) {
    cout << 0;
    return 0;
  }
  Kmax = 1 << k;
  if (distinct < Kmax) {
    cout << "0";
    return 0;
  }
  int sum[n];
  sum[0] = freq[0];
  for (int i = 1; i < distinct; i++) sum[i] = sum[i - 1] + freq[i];
  int ans = sum[Kmax - 1];
  for (int i = Kmax; i < distinct; i++) ans = max(ans, sum[i] - sum[i - Kmax]);
  ans = n - ans;
  cout << ans;
}
