#include <bits/stdc++.h>
using namespace std;
long long n, k;
int arr[400009];
map<int, int> mp;
vector<int> v;
int sum[400009];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (mp[arr[i]] == 0) {
      v.push_back(arr[i]);
    }
    mp[arr[i]]++;
  }
  sort(v.begin(), v.end());
  k *= 8;
  int ans = 1000000009;
  int j = 0;
  int num = 0;
  int curr = 0;
  for (int i = 0; i < v.size(); i++) {
    curr += mp[v[i]];
  }
  for (int i = 0; i < v.size(); i++) {
    while (j < v.size() && ceil(log2(j - i + 1)) * n <= k) {
      curr -= mp[v[j]];
      j++;
    }
    ans = min(ans, curr);
    j = max(i, j);
    curr += mp[v[i]];
  }
  cout << ans << endl;
}
