#include <bits/stdc++.h>
using namespace std;
long long int MOD = 998244353;
long long int mod = 1e9 + 7;
long long int INF = 1e18;
long long int dx[] = {1, -1, -1, 1};
long long int dy[] = {1, -1, 1, -1};
long long int binpow(long long int a, long long int b) {
  if (b == 0) return 1;
  long long int res = binpow(a, b / 2);
  if (b % 2 == 1)
    return res * res * a;
  else
    return res * res;
}
long long int loga(long long int n) {
  double ans = (log((double)n)) / (log(2.0));
  ans = ceil(ans);
  return (long long int)ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  m = m * 8;
  map<long long int, long long int> k;
  long long int a[n];
  vector<long long int> freq;
  freq.push_back(0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    k[a[i]]++;
  }
  if (n * loga(k.size()) <= m)
    m = k.size();
  else {
    m = m / n;
    m = binpow(2, m);
  }
  for (auto j : k) {
    freq.push_back(j.second);
  }
  for (int i = 2; i < freq.size(); i++) freq[i] = freq[i] + freq[i - 1];
  if (m + 1 >= freq.size())
    cout << 0;
  else {
    long long int ans = 0;
    for (int i = m; i < freq.size(); i++) ans = max(ans, freq[i] - freq[i - m]);
    cout << freq[freq.size() - 1] - ans;
  }
  return 0;
}
