#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const int maxn = 4e5 + 5;
long long ma[maxn], mb[maxn];
map<long long, long long> mp;
set<long long> s;
long long quick_pow(long long x, long long p) {
  long long ans = 1;
  while (p) {
    if (p & 1) {
      ans = ans * x;
    }
    x = x * x;
    p = p >> 1;
  }
  return ans;
}
int main() {
  long long n, I;
  scanf("%lld%lld", &n, &I);
  for (long long i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    mp[x]++;
    s.insert(x);
  }
  long long k = s.size(), a;
  for (long long i = 0; i <= 32; i++) {
    if ((1 << i) >= k) {
      a = i;
      break;
    }
  }
  if (n * a <= 8 * I) {
    cout << 0 << endl;
    return 0;
  }
  long long sk = quick_pow(2, 8 * I / n);
  set<long long>::iterator it, is;
  long long sum = 1e15, zz = 1;
  while (!s.empty()) {
    it = s.begin();
    ma[zz++] = *it;
    s.erase(it);
  }
  mb[0] = 0;
  for (long long i = 1; i < zz; i++) {
    mb[i] = mb[i - 1] + mp[ma[i]];
  }
  for (int i = sk; i < zz; i++) {
    sum = min(sum, n - mb[i] + mb[i - sk]);
  }
  printf("%lld\n", sum);
  return 0;
}
