#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e18;
const int N = 4e5 + 1;
int n, a[N], k, sum[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  int test = 1;
  while (test--) {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    vector<int> v;
    v.push_back(0);
    a[0] = -1;
    for (int i = 1; i <= n; i++) {
      if (a[i] != a[i - 1])
        v.push_back(1);
      else
        v.back()++;
    }
    sum[0] = 0;
    for (int i = 1; i < v.size(); i++) {
      sum[i] = sum[i - 1] + v[i];
    }
    k = k * 8 / n;
    int mx = 1;
    for (int i = 1; i <= k; i++) {
      mx *= 2;
      if (mx > n) break;
    }
    mx = min(mx, n);
    int ans = n;
    for (int i = 1; i < v.size(); i++) {
      int it = min(i + mx - 1, (int)v.size() - 1);
      ans = min(ans, n - (sum[it] - sum[i - 1]));
    }
    cout << ans << endl;
  }
}
