#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
bool mod(long double a, long double b) { return a / b - floor(a / b); }
long long power(long long first, long long n) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = result * first;
    first = first * first;
    n = n / 2;
  }
  return result;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, I;
  cin >> n >> I;
  vector<long long> v(n);
  for (long long &first : v) cin >> first;
  set<long long> s;
  for (long long i = 0; i < n; i++) s.insert(v[i]);
  long long K = s.size();
  long long k = (8 * I) / n;
  if (k > 33) {
    cout << 0;
    return 0;
  }
  long long temp = power(2, k);
  if (K <= temp) {
    cout << 0;
    return 0;
  }
  map<long long, long long> m;
  for (long long first : v) m[first]++;
  vector<long long> ans;
  for (auto it : m) ans.emplace_back(it.second);
  long long flag = K - temp, sum = 0;
  for (long long i = 0; i < flag; i++) sum += ans[i];
  long long mn = sum, momo = 1;
  for (long long i = ans.size() - 1; i > ans.size() - flag; i--) {
    sum -= ans[flag - momo];
    sum += ans[i];
    momo++;
    mn = min(mn, sum);
  }
  cout << mn << '\n';
}
