#include <bits/stdc++.h>
using namespace std;
int n, kk, a[500010], b[500010];
int sum1[500010], sum2[500010], sum3[500010], num[500010], k1[500010],
    k2[500010], k3[500010];
unordered_map<int, int> mp;
int main() {
  scanf("%d%d", &n, &kk);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  b[1] = a[1];
  mp[b[1]] = 1;
  int k = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] != b[k]) {
      k++;
      b[k] = a[i];
      mp[b[k]] = k;
    }
  }
  int p = (kk * 8) / n;
  int kind = 1;
  for (int i = 1; i <= p; i++) {
    kind = kind * 2;
    if (kind >= k) {
      printf("0\n");
      return (0);
    }
  }
  int res = k - kind;
  for (int i = 1; i <= n; i++) num[mp[a[i]]]++;
  for (int i = 1; i <= k; i++) {
    sum1[i] = sum1[i - 1] + num[i];
    k1[i] = k1[i - 1] + (num[i] > 0);
  }
  for (int i = k; i >= 1; i--) {
    sum2[i] = sum2[i + 1] + num[i];
    k2[i] = k2[i + 1] + (num[i] > 0);
  }
  for (int i = 1; i <= k; i++) {
    sum3[i] = sum2[k - i + 1];
    k3[i] = k2[k - i + 1];
  }
  int ans = 1e9 + 7;
  for (int i = 1; i <= k; i++) {
    int x = res - k1[i];
    if (x <= 0) ans = min(ans, sum1[i]);
    int l = lower_bound(k3 + 1, k3 + 1 + k - i, x) - k3;
    if (l != k + 1 - i) {
      ans = min(ans, sum1[i] + sum3[l]);
    }
  }
  for (int i = 1; i <= k; i++) {
    int x = res - k3[i];
    if (x <= 0) ans = min(ans, sum3[i]);
  }
  printf("%d\n", ans);
  return (0);
}
