#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
int raw[maxn], prefix[maxn];
int main() {
  int n, disk, ans = 0;
  scanf("%d%d", &n, &disk);
  for (int i = 1; i <= n; i++) scanf("%d", &raw[i]);
  sort(raw + 1, raw + n + 1);
  int point = 0;
  raw[0] = -1;
  for (int i = 1; i <= n; i++) {
    if (raw[i] != raw[i - 1]) point++;
    prefix[point]++;
  }
  if (disk * 8 / n >= 20) {
    cout << 0;
    return 0;
  }
  int siz_1 = 1 << (disk * 8 / n);
  if (siz_1 >= point) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i <= point; i++) prefix[i] += prefix[i - 1];
  for (int i = 1; i <= point - siz_1 + 1; i++) {
    int r = i + siz_1 - 1;
    int tmp = prefix[r] - prefix[i - 1];
    ans = max(ans, tmp);
  }
  ans = n - ans;
  cout << ans;
}
