#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, size;
  cin >> n >> size;
  vector<int> nums(n);
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
  }
  sort(nums.begin(), nums.end());
  int bits = size * 8 / n;
  int pow = (bits < 30 ? (1 << bits) : n);
  ;
  int begin = 0, end = 0;
  int res = n;
  int k = 1;
  for (; end < n;) {
    for (; end < n - 1 && nums[end] == nums[end + 1]; end++) {
    }
    if (n - end + begin - 1 < res) {
      res = n - end + begin - 1;
    }
    k++;
    end++;
    if (k > pow) {
      k--;
      for (; begin < n - 1 && nums[begin] == nums[begin + 1]; begin++) {
      }
      begin++;
    }
  }
  cout << res << "\n";
}
