#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int n, k;
  cin >> n >> k;
  long long int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  k = k * 8;
  sort(a, a + n);
  vector<long long int> v;
  long long int count = 1;
  for (long long int i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      v.emplace_back(count);
      count = 1;
    } else {
      count++;
    }
  }
  v.emplace_back(count);
  long long int d = v.size();
  long long int start = 0;
  long long int end = d - 1;
  long long int di = 0;
  for (long long int i = d; i >= 1; i--) {
    long long int p = i - 1;
    long long int o = 0;
    while (p != 0) {
      p = p / 2;
      o++;
    }
    if (o * n <= k) {
      break;
    } else {
      di++;
    }
  }
  long long int ans = 0;
  for (long long int i = 0; i < di; i++) {
    ans += v[i];
  }
  long long int u = 1;
  long long int o = ans;
  while (di != 0) {
    o -= v[di - 1];
    o += v[d - u];
    u++;
    di--;
    ans = min(o, ans);
  }
  cout << ans;
  return 0;
}
