#include <bits/stdc++.h>
using namespace std;
const int N = 400010;
int n, I, dang, l, r, k, dapan = 1000000007;
int a[N], dem[N], L[N], R[N];
vector<int> b;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> I;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  b.push_back(-1);
  b.push_back(a[1]);
  dem[1] = 1;
  dang = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] == a[i - 1]) {
      dem[dang]++;
    } else {
      b.push_back(a[i]);
      dang++;
      dem[dang] = 1;
    }
  }
  for (int i = 2; i <= dang; i++) L[i] = L[i - 1] + dem[i - 1];
  for (int i = dang - 1; i >= 1; i--) R[i] = R[i + 1] + dem[i + 1];
  for (int i = 1; i <= dang; i++) {
    l = i;
    r = dang;
    while (l <= r) {
      int mid = (l + r) / 2;
      int khoang_cach = mid - i + 1;
      int soluong = 0;
      int thaydoi = 0;
      k = ceil(log2(khoang_cach));
      soluong = n * k;
      thaydoi = L[i] + R[mid];
      if (soluong > 8 * I) {
        r = mid - 1;
      } else {
        dapan = min(thaydoi, dapan);
        l = mid + 1;
      }
    }
  }
  cout << dapan;
  return 0;
}
