#include <bits/stdc++.h>
using namespace std;
long double const pi = 3.141592653589793238462;
long long int const mod = 1e9 + 7;
long long int power(long long int a, long long int b) {
  long long int f = 1;
  while (b > 0) {
    if (b & 1) {
      f = f * a;
      f %= mod;
    }
    a = a * a;
    a %= mod;
    b = b / 2;
  }
  return f;
}
long long int inverse(long long int x) { return power(x, mod - 2); }
long long int const N = 1e5 + 5;
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, k, i, j, l;
  cin >> n >> k;
  long long int a[n];
  vector<long long int> b(n);
  for (i = 0; i < n; i++) cin >> a[i];
  b[0] = 1;
  sort(a, a + n);
  for (i = 1; i < n; i++) {
    b[i] = b[i - 1];
    if (a[i] != a[i - 1]) b[i]++;
  }
  long long int size = k * (8LL);
  long long int x = size / n;
  long long int mxx = 20;
  x = min(x, mxx);
  long long int y = (1 << x);
  long long int ans;
  if (y >= n) {
    cout << "0" << endl;
    return 0;
  }
  ans = n - y;
  for (i = y; i < n; i++) {
    long long int f = b[i] - y;
    long long int p = lower_bound(b.begin(), b.end(), f + 1) - b.begin();
    p--;
    ans = min(ans, n - i - 1 + max(0LL, p + 1));
  }
  cout << ans << endl;
  return 0;
}
