#include <bits/stdc++.h>
using namespace std;
int a[400005], pre[400005];
map<int, int> mp;
bool cmp(const int &a, const int &b) { return mp[a] < mp[b]; }
int main() {
  int n, I, K;
  scanf("%d%d", &n, &I);
  I *= 8;
  int l = 1, r = n, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (mid == 1) {
      K = 1;
      l = mid + 1;
      continue;
    }
    if ((int(log2(mid - 1) + 1e-6) + 1) * n <= I) {
      K = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    mp[a[i]]++;
  }
  sort(a + 1, a + n + 1);
  vector<int> ai;
  ai.push_back(-1);
  ai.push_back(a[1]);
  for (int i = 2; i <= n; i++)
    if (a[i] != a[i - 1]) ai.push_back(a[i]);
  int sum = 0, ans = n;
  int tmpn = n;
  n = ai.size() - 1;
  for (int i = 1; i <= n; i++) {
    sum += mp[ai[i]];
    pre[i] = sum;
  }
  K = min(K, n);
  for (int i = 1; i + K - 1 <= n; i++) {
    int l = i, r = i + K - 1;
    int tmp = pre[l - 1] + pre[n] - pre[r];
    ans = min(ans, tmp);
  }
  if (ans != tmpn)
    printf("%d", ans);
  else
    printf("%d", n - 1);
  return 0;
}
