#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
void fast() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fast();
  lli q;
  q = 1;
  while (q--) {
    lli n, bbb, i, j, k, m, p;
    cin >> n >> bbb;
    bbb = bbb * 8;
    bbb = bbb / n;
    k = 1;
    for (int i = 0; i < bbb; i++) k *= 2;
    vector<lli> a(n), b(n), bb(n);
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    j = 0;
    b[j] = a[0], bb[j] = 1;
    for (i = 1; i < n; i++) {
      if (a[i] != a[i - 1]) {
        j++;
        b[j] = a[i];
        bb[j] = 1;
      } else {
        bb[j]++;
      }
    }
    int ma = 0, s = 0;
    for (i = 0; i < k; i++) {
      s = s + bb[i];
      if (i == j) break;
    }
    ma = s;
    for (i = k; i <= j; i++) {
      s = s + bb[i] - bb[i - k];
      ma = max(ma, s);
    }
    cout << n - ma << "\n";
  }
}
