#include <bits/stdc++.h>
using namespace std;
int N, I, K;
vector<int> v;
map<int, int> mp;
int main() {
  scanf("%d%d", &N, &I);
  I *= 8;
  K = I / N;
  K = min(K, 25);
  K = (1 << K);
  for (int i = 1; i <= N; i++) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  sort(begin(v), end(v));
  int j = 0, dif = 0;
  int ans = N;
  for (int i = 0; i < N; i++) {
    while (j < N) {
      if (dif == K && mp[v[j]] == 0) break;
      mp[v[j]]++;
      if (mp[v[j]] == 1) dif++;
      j++;
    }
    ans = min(ans, N - (j - i));
    mp[v[i]]--;
    if (mp[v[i]] == 0) dif--;
  }
  printf("%d\n", ans);
  return 0;
}
