#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long m;
  scanf("%d %lld", &n, &m);
  vector<int> v(n);
  for (auto& e : v) scanf("%d", &e);
  int k = (m * 8) / n;
  k = min(k, 30);
  vector<pair<int, int>> P;
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    int x = 0;
    int j;
    for (j = i; j < n && v[j] == v[i]; j++)
      ;
    x = j - i;
    P.push_back({i, x});
    i = j - 1;
  }
  for (int i = 1; i < P.size(); i++) P[i].second += P[i - 1].second;
  int ret = n;
  for (int i = 0; i < P.size(); i++) {
    int to_try = n;
    int last = min(i + (1 << k) - 1, (int)P.size() - 1);
    to_try -= P[last].second;
    to_try += i > 0 ? P[i - 1].second : 0;
    ret = min(ret, to_try);
  }
  printf("%d\n", ret);
  return 0;
}
