#include <bits/stdc++.h>
using namespace std;
const int M = 4e5 + 5;
int a[M];
map<int, int> mp;
int main() {
  int n, k;
  cin >> n >> k;
  int m = 1;
  for (int i = 1; i <= 8 * k / n; i++) {
    m <<= 1;
    if (m >= n) {
      m = n;
      break;
    }
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  int countt = 0, ans = 0;
  ;
  for (int i = 1, j = 1; i <= n; i++) {
    if (!mp[a[i]]) countt++;
    mp[a[i]]++;
    for (; countt > m; j++) {
      mp[a[j]]--;
      if (!mp[a[j]]) countt--;
    }
    ans = max(i - j + 1, ans);
  }
  cout << n - ans << endl;
  return 0;
}
