#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const ld pi = acos(0) * 2;
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
template <typename CT, typename T>
inline void reset_container(CT &c, int sz, T v) {
  c.resize(sz);
  for (auto &x : c) x = v;
}
ll I;
ll sz = 1;
int n;
int a[400001];
vector<pair<int, int>> v;
int main() {
  read(n);
  read(I);
  I *= 8;
  for (int i = (1); i <= (n); i++) read(a[i]);
  for (int i = (1); i <= (60); i++) {
    if ((ll(n)) * i <= I)
      sz *= 2;
    else
      break;
  }
  sort(a + 1, a + n + 1);
  v.push_back(make_pair(-1, 0));
  for (int i = (1); i <= (n); i++)
    if (v.back().first != a[i])
      v.push_back(make_pair(a[i], 1));
    else
      v.back().second++;
  sz = min(sz, ((ll)v.size()) - 1);
  for (int i = (1); i < (v.size()); i++) v[i].second += v[i - 1].second;
  int f = 0;
  for (int i = (sz); i < (v.size()); i++) {
    f = max(f, v[i].second - v[i - sz].second);
  }
  f = n - f;
  writeln(f);
}
