#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, k;
  cin >> n >> k;
  k = k * 8;
  vector<long long int> ar(n);
  set<long long int> u;
  for (auto &i : ar) {
    cin >> i;
    u.insert(i);
  }
  float p = u.size();
  long long int size = ceil(log2(p)) * n;
  if (size <= k) {
    cout << "0";
    return 0;
  }
  map<long long int, long long int> mp;
  long long int TEMP = -1;
  sort(ar.begin(), ar.end());
  for (auto &i : ar) {
    cin >> i;
    if (!mp.count(i)) mp[i] = ++TEMP;
  }
  vector<long long int> v;
  for (auto &i : ar) v.push_back(mp[i]);
  assert(v.size() == ar.size());
  ar = v;
  sort(ar.begin(), ar.end());
  long long int low = 1, high = 1e10;
  long long int need_val;
  while (low <= high) {
    long long int mid = low + (high - low) / 2;
    double r = ceil(log2(mid));
    if (n * r <= k) {
      need_val = mid;
      low = mid + 1;
    } else
      high = mid - 1;
  }
  long long int mini = ar[0], maxi = ar[n - 1];
  long long int changes = n;
  for (long long int i = mini; i + need_val - 1 <= maxi; i++) {
    long long int x = i, y = i + need_val - 1;
    long long int temp1 = lower_bound(ar.begin(), ar.end(), x) - ar.begin();
    long long int temp2 = ar.end() - upper_bound(ar.begin(), ar.end(), y);
    changes = min(changes, temp1 + temp2);
  }
  cout << changes;
  return 0;
}
