#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 5;
int n, I;
int cnt[maxn];
int a[maxn], b[maxn];
void ReadInput() {
  cin >> n >> I;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  int k = 1;
  b[1] = 1;
  for (int i = 2; i <= n; ++i)
    if (a[i] != a[i - 1])
      b[i] = ++k;
    else
      b[i] = k;
}
int Get(int x) {
  long long tmp = 1;
  int res = 0;
  while (tmp * 2 <= x) {
    tmp *= 2;
    res++;
  }
  if (tmp < x) res++;
  return res;
}
bool Check(int k) {
  fill(begin(cnt), end(cnt), 0);
  int c = 0;
  for (int i = 1; i <= k; ++i) {
    cnt[b[i]]++;
    if (cnt[b[i]] == 1) c++;
  }
  int mem = Get(c);
  if ((long long)mem * n <= 8LL * I) return true;
  int l = 2, r = k + 1;
  while (r <= n) {
    cnt[b[l - 1]]--;
    if (cnt[b[l - 1]] == 0) c--;
    cnt[b[r]]++;
    if (cnt[b[r]] == 1) c++;
    int mem = Get(c);
    if ((long long)mem * n <= 8LL * I) return true;
    l++;
    r++;
  }
  return false;
}
void Solve() {
  int low = 1, high = n;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (Check(mid))
      low = mid + 1;
    else
      high = mid - 1;
  }
  cout << n - high;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ReadInput();
  Solve();
}
