#include <bits/stdc++.h>
using namespace std;
int a[400003], s[400003];
int sum1[400003], sum2[400003];
int main() {
  int n, i;
  cin >> n >> i;
  int k = i * 8 / n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int cnt = 0, loc = 0;
  for (int i = 1; i <= n; i++) {
    if (i == 1 || a[i] == a[i - 1])
      cnt++;
    else {
      s[++loc] = cnt;
      cnt = 1;
    }
    if (i == n) s[++loc] = cnt;
  }
  if (k > 20) {
    cout << 0;
    return 0;
  }
  k = (1 << k);
  k = loc - k;
  if (k <= 0) {
    cout << 0;
    return 0;
  }
  int l = 1, r = loc;
  int ans = 1e9;
  sum1[1] = s[1];
  for (int i = 2; i <= loc; i++) sum1[i] = s[i] + sum1[i - 1];
  sum2[1] = s[loc];
  for (int i = loc - 1; i >= 1; i--) sum2[loc - i + 1] = s[i] + sum2[loc - i];
  for (int i = 0; i <= loc; i++) {
    if (k >= i) ans = min(ans, sum1[i] + sum2[k - i]);
  }
  cout << ans;
}
