#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int maxm = 305;
long long arr[maxn];
long long arr1[maxn];
const long long mod = (long long)(998244353);
vector<long long> edges[maxn];
long long n, m, v, k, q, D, H, a, b, c, h, d, x, y, z, t;
string s, s1, s2;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long par[maxn];
void init() {
  for (int i = 0; i < maxn; i++) par[i] = i;
}
long long find(int i) {
  if (par[i] != i) {
    return par[i] = find(par[i]);
  } else
    return i;
}
void merge(int x, int y) { par[find(x)] = par[find(y)]; }
long long presum[100];
long long ans[100];
string input[maxn];
bool isVowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    return true;
  else
    return false;
};
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  k *= 8;
  long long d = k / n;
  if (d > 32) {
    cout << 0 << endl;
    return 0;
  }
  d = pow(2, d);
  long long ret = 999999;
  int l = 0;
  int r = 0;
  map<long long, long long> cnt;
  while (r < n) {
    cnt[arr[r]]++;
    if (cnt.size() <= d) {
      ret = min(ret, n - (r - l + 1));
    } else {
      while (cnt.size() > d) {
        cnt[arr[l]]--;
        if (cnt[arr[l]] == 0) {
          cnt.erase(cnt.find(arr[l]));
        }
        l++;
      }
      ret = min(ret, n - (r - l + 1));
    }
    r++;
  }
  cout << ret << endl;
  return 0;
}
