#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
int a[N], b[N];
map<int, int> vis;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (!vis[a[i]]) {
      vis[a[i]]++;
    }
  }
  sort(a + 1, a + 1 + n);
  int head = 1, index = 1;
  b[head] = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] == a[index]) {
      b[head]++;
    } else {
      head++;
      index = i;
      b[head] = b[head - 1] + 1;
    }
  }
  int ans = 0;
  int p = (8 * k) / n, len = 1;
  for (int i = 1; i <= p; i++) {
    len <<= 1;
    if (len > head) {
      puts("0");
      return 0;
    }
  }
  for (int i = len; i <= head; i++) {
    ans = max(ans, b[i] - b[i - len]);
  }
  cout << n - ans << endl;
  return 0;
}
