#include <bits/stdc++.h>
using namespace std;
long long int bin_expo(long long int a, long long int b, long long int m) {
  long long int res = 1;
  a %= m;
  while (b != 0) {
    if (b % 2 == 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b = b / 2;
  }
  return res;
}
int main() {
  int n, k;
  cin >> n >> k;
  int x = (k * 8) / n;
  int ar[n];
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    mp[ar[i]]++;
  }
  int sum = 0;
  int a = mp.size();
  int val = 1;
  while (x > 0 && val < a) {
    x--;
    val = val * 2;
  }
  if (x == 0 && val < a) {
    val = a - val;
    vector<int> v;
    for (auto it : mp) {
      v.push_back(it.second);
    }
    int ar[v.size()], br[v.size() + 2];
    ar[0] = v[0];
    for (int i = 1; i < v.size(); i++) {
      ar[i] = ar[i - 1] + v[i];
    }
    br[v.size() - 1] = v[v.size() - 1];
    for (int i = v.size() - 2; i >= 0; i--) {
      br[i] = br[i + 1] + v[i];
    }
    int ans = br[v.size() - val];
    br[v.size()] = 0;
    for (int i = 0; i < val; i++) {
      ans = min(ans, ar[i] + br[v.size() - val + i + 1]);
    }
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}
