#include <bits/stdc++.h>
using namespace std;
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
inline void Cin(T& x) {
  char c = getchar();
  x = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
}
template <typename T, typename... Args>
inline void Cin(T& a, Args&... args) {
  Cin(a);
  Cin(args...);
}
const long long base = 1331;
const long long N = 5e5 + 5;
long long n;
long long a[N];
long long I;
long long dis[N];
long long findlog(long long x) {
  long long l = 0, r = 64, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if ((1ll << mid) >= x)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return l;
}
bool ch(long long x) { return (n * findlog(x) <= I); }
void read(void) {
  cin >> n >> I;
  I *= 8;
  for (long long i = 1; i <= (long long)(n); ++i) cin >> a[i];
  long long l = 1, r = n, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (ch(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  a[0] = -1;
  sort(a + 1, a + 1 + n);
  for (long long i = 1; i <= (long long)(n); ++i) {
    dis[i] = dis[i - 1];
    if (a[i] != a[i - 1]) dis[i]++;
  }
  long long ans = INT_MAX;
  for (long long i = 1; i <= (long long)(n); ++i) {
    if (dis[i] == dis[i - 1]) continue;
    long long j = upper_bound(dis + 1, dis + 1 + n, dis[i] + r - 1) - dis - 1;
    ans = min(ans, i - 1 + n - j);
  }
  cout << ans;
}
signed main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read();
}
