#include <bits/stdc++.h>
using namespace std;
template <class T>
bool tomax(T &x, T y) {
  if (x < y) return x = y, 1;
  return 0;
}
template <class T>
bool tomin(T &x, T y) {
  if (x > y) return x = y, 1;
  return 0;
}
int A[400005], n, K;
int cnt[400005], B[400005], res;
void Add(int x, int v) {
  if (cnt[x] == 0 && v > 0) res++;
  if (cnt[x] == 1 && v < 0) res--;
  cnt[x] += v;
}
bool Check() {
  int p = log2(res);
  if (1.0 * pow(2, p) != 1.0 * res) p++;
  return 1LL * p * n <= 8LL * K;
}
bool check(int x) {
  if (x == n) return 1;
  memset(cnt, 0, sizeof(cnt));
  x = n - x;
  res = 0;
  for (int i = 1; i <= x; i++) Add(A[i], 1);
  if (Check()) return 1;
  for (int i = x + 1; i <= n; i++) {
    Add(A[i - x], -1), Add(A[i], 1);
    if (Check()) return 1;
  }
  return 0;
}
int main() {
  cin >> n >> K;
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]), B[i] = A[i];
  sort(B + 1, B + 1 + n);
  int len = unique(B + 1, B + 1 + n) - B - 1;
  for (int i = 1; i <= n; i++) A[i] = lower_bound(B + 1, B + 1 + len, A[i]) - B;
  sort(A + 1, A + 1 + n);
  int L = 0, R = n, ans = 0;
  while (L <= R) {
    int mid = L + R >> 1;
    if (check(mid))
      ans = mid, R = mid - 1;
    else
      L = mid + 1;
  }
  printf("%d\n", ans);
  return 0;
}
