#include <bits/stdc++.h>
using namespace std;
long long t, n, i, j, k, l, m, p[23], a[401010], b[401010], aa[101010],
    bb[101010];
map<long long, long long> v;
const int maxn = 100010;
string s1, s2, s3, s4;
map<long long, long long> q;
set<long long> qq;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> m;
    q[m]++;
    qq.insert(m);
  }
  for (auto x : qq) {
    a[++j] = q[x];
  }
  for (i = 1; i <= j; i++) {
    a[i] += a[i - 1];
  }
  m = j;
  while (ceil(log2(m)) * n > 8 * k) {
    m--;
  }
  long long mi = 1e18;
  for (i = m; i <= j; i++) {
    mi = min(mi, n - (a[i] - a[i - m]));
  }
  cout << mi;
}
