#include <bits/stdc++.h>
using namespace std;
void swapp(int &a, int &b);
double fabss(double a);
int maxx(int a, int b);
int minn(int a, int b);
int Del_bit_1(int n);
int lowbit(int n);
int abss(int a);
const double E = 2.718281828;
const double PI = acos(-1.0);
const int inf = (1 << 29);
const double ESP = 1e-9;
const int mod = (int)1e9 + 7;
const int N = (int)5e5 + 10;
int a[N], b[N];
bool mark[N];
int cnt[N];
int s[N], dp[N];
int n;
void LS() {
  int m = 0;
  for (int i = 1; i <= n; ++i) b[++m] = a[i];
  sort(b + 1, b + 1 + m);
  m = unique(b + 1, b + 1 + m) - b - 1;
  for (int i = 1; i <= n; ++i) a[i] = lower_bound(b + 1, b + 1 + m, a[i]) - b;
  return;
}
int main() {
  int k, temp = 1;
  scanf("%d%d", &n, &k);
  k *= 8;
  k /= n;
  for (register int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  LS();
  int tot = 0;
  for (register int i = 1; i <= n; ++i) {
    if (!mark[a[i]]) s[++tot] = a[i], mark[a[i]] = 1;
    cnt[a[i]]++;
  }
  while (k--) {
    temp *= 2;
    if (temp >= tot) {
      printf("0\n");
      return 0;
    }
  }
  sort(s + 1, s + 1 + tot);
  for (register int i = 1; i <= tot; ++i) dp[i] = dp[i - 1] + cnt[s[i]];
  int ans = inf;
  for (int i = 1; i + temp - 1 <= tot; ++i) {
    ans = minn(dp[i - 1] + dp[tot] - dp[i + temp - 1], ans);
  }
  printf("%d\n", ans);
  return 0;
}
int maxx(int a, int b) { return a > b ? a : b; }
void swapp(int &a, int &b) { a ^= b ^= a ^= b; }
int lowbit(int n) { return n & (-n); }
int Del_bit_1(int n) { return n & (n - 1); }
int abss(int a) { return a > 0 ? a : -a; }
double fabss(double a) { return a > 0 ? a : -a; }
int minn(int a, int b) { return a < b ? a : b; }
