#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 5;
int a[maxn];
int dp[maxn];
int dif[maxn];
int n, I, k;
int main() {
  scanf("%d%d", &n, &I);
  I *= 8;
  k = I / n;
  k = 1 << min(k, 20);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + n + 1);
  dp[0] = 0;
  int num = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i - 1]) {
      dp[i] = dp[i - 1] + 1;
      dif[num++] = i;
    } else {
      dp[i] = dp[i - 1];
    }
  }
  int res = 0;
  if (k >= num) res = n;
  for (int i = 0; i + k < num; i++) {
    res = max(dif[i + k] - dif[i], res);
  }
  printf("%d", n - res);
}
