#include <bits/stdc++.h>
using namespace std;
long long nx2(long long n) {
  long long p = 1;
  if (n && !(n & (n - 1))) return n;
  while (p < n) p <<= 1;
  return p;
}
namespace Debug {
void dout() { cerr << "\n"; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << " " << H;
  dout(T...);
}
template <typename T>
void douta(const T *a, int n) {
  cerr << "\n[";
  for (int i = 0; i < n; i++) {
    cerr << " " << a[i];
  }
  cerr << " ]\n";
}
template <typename T>
void doutaa(T **b, int r, int c) {
  for (int i = 0; i < r; i++) {
    cerr << "[";
    for (int j = 0; j < c; j++) {
      cerr << " " << b[i][j];
    }
    cerr << " ]\n";
  }
}
template <typename T>
void dout(const vector<T> v) {
  cerr << "\n[";
  for (T i : v) {
    cerr << " " << i;
  }
  cerr << " ]\n";
}
template <typename T>
void dout(const vector<vector<T>> v) {
  cerr << "\n";
  for (vector<T> u : v) {
    cerr << "[";
    for (T i : u) {
      cerr << " " << i;
    }
    cerr << " ]\n";
  }
}
template <typename F, typename S>
void dout(const vector<pair<F, S>> u) {
  cerr << "\n";
  for (pair<F, S> v : u) {
    cerr << "[ " << v.first << " " << v.second << " ]\n";
  }
}
}  // namespace Debug
using namespace Debug;
int n, I, K;
vector<int> a;
int main() {
  cin >> n >> I;
  a.assign(n, 0);
  unordered_map<int, int> ump;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ++ump[a[i]];
  }
  int l = 0, r = ump.size(), m;
  while (l < r) {
    m = l + (r - l + 1) / 2;
    if (n * ceil(log2(m)) <= 8 * I) {
      l = m;
    } else {
      r = m - 1;
    }
  }
  K = l;
  vector<pair<int, int>> b(ump.begin(), ump.end());
  sort(b.begin(), b.end());
  int cnt = 0, freq = 0, mxfreq = 0;
  while (cnt < (int)(b).size() && cnt < K) {
    freq += b[cnt++].second;
  }
  (mxfreq) = max((mxfreq), (freq));
  ;
  while (cnt < (int)(b).size()) {
    freq -= b[cnt - K].second;
    freq += b[cnt++].second;
    (mxfreq) = max((mxfreq), (freq));
    ;
  }
  cout << n - mxfreq << '\n';
}
