#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  int t;
  cin >> n >> i;
  t = (i * 8) / n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  vector<int> B(1, 0);
  int cur = A[0];
  int j = 0;
  for (int i = 0; i < n; i++) {
    if (A[i] == cur) {
      B[j]++;
    } else {
      cur = A[i];
      B.push_back(1);
      j++;
    }
  }
  int m = j + 1;
  int tmp;
  tmp = t;
  t = 1;
  while (tmp > 0) {
    t = t * 2;
    if (t > m) {
      t = m;
      break;
    }
    tmp--;
  }
  int sum = 0;
  int ans;
  for (int i = 0; i < min(m, t); i++) {
    sum += B[i];
  }
  ans = sum;
  int r = min(m - 1, t - 1);
  int l = 0;
  while (r < m - 1) {
    sum += B[r + 1];
    sum -= B[l];
    ans = max(ans, sum);
    l++;
    r++;
  }
  cout << n - ans;
}
