#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &x : a) cin >> x;
  k = (k * 8) / n;
  int dis = pow(2, k);
  sort(a.begin(), a.end());
  vector<int> pref(n + 1, -1);
  pref[0] = 0;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] == a[i])
      pref[i] = pref[i - 1];
    else
      pref[i] = pref[i - 1] + 1;
  }
  vector<int> cnt;
  for (int i = 0; i < n; i++) {
    if (pref[i] != pref[i + 1]) cnt.push_back(i);
  };
  ;
  ;
  if (dis >= cnt.size()) {
    cout << "0\n";
    return 0;
  }
  int ans = n - (cnt[dis - 1] + 1);
  ;
  for (int i = 1; i < cnt.size() - dis + 1; i++) {
    ;
    ans = min(ans, (n - (cnt[i + dis - 1] - cnt[i - 1])));
  }
  cout << ans << "\n";
  return 0;
}
