#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << " ";
  err(++it, args...);
}
long long power(long long x, long long y, long long p = 1000000007) {
  x %= p;
  long long val = 1;
  while (y) {
    if (y & 1LL) val = (val * x) % p;
    y >>= 1LL;
    x = (x * x) % p;
  }
  return val;
}
long long a[400005];
map<long long, long long> f;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, I;
  cin >> n >> I;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  long long ans = 1e8;
  long long p = 8 * I / n;
  long long cp = p;
  p = 1;
  while (cp--) {
    p *= 2;
    if (p > n) {
      cout << 0 << '\n';
      return 0;
    }
  }
  long long j = 1;
  long long cnt = 0;
  for (long long i = 1; i <= n; i++) {
    while (j <= n) {
      if (f.count(a[j]) == 0 || f[a[j] == 0]) {
        if (cnt == p) break;
        f[a[j]]++;
        cnt++;
        j++;
        continue;
      }
      f[a[j]]++;
      j++;
    }
    ans = min(ans, i - 1 + n - j + 1);
    f[a[i]]--;
    if (f[a[i]] == 0) cnt--;
  }
  cout << ans << '\n';
}
