#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[500000];
  set<int> st;
  map<int, int> mp;
  vector<int> b;
  vector<int> c;
  int d[500000];
  int e[500000];
  int n, k;
  int x, y, z;
  int s, ans;
  bool v = true;
  ans = 0;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < int(n); i++) {
    scanf("%d", &a[i]);
    if (st.count(a[i]) == 0) {
      st.insert(a[i]);
      b.push_back(a[i]);
      c.push_back(0);
    }
  }
  sort(b.begin(), b.end());
  for (int i = 0; i < int(b.size()); i++) mp[b[i]] = i;
  for (int i = 0; i < int(n); i++) c[mp[a[i]]]++;
  k = 8 * k;
  k = k / n;
  if (k > 20) {
    printf("0\n");
    return 0;
  }
  x = 1;
  for (int i = 0; i < int(k); i++) x = x * 2;
  k = x;
  if (b.size() <= k) {
    printf("0\n");
    return 0;
  }
  d[0] = 0;
  for (int i = 0; i < int(b.size()); i++) d[i + 1] = d[i] + c[i];
  e[n] = 0;
  for (int i = b.size() - 1; i >= 0; i--) e[i] = e[i + 1] + c[i];
  ans = n;
  for (int i = 0; i < int(b.size() - k + 1); i++) {
    s = d[i] + e[k + i];
    ans = min(ans, s);
  }
  printf("%d\n", ans);
  return 0;
}
