#include <bits/stdc++.h>
using namespace std;
long long int pwr(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x;
    }
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long int mpwr(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
void prime1(long long int n, vector<long long int>& a) {
  long long int i, j;
  vector<bool> mark(n, false);
  for (i = 2; i * i < n; i++) {
    if (mark[i] == false) {
      for (j = 2 * i; j < n; j += i) {
        mark[j] = true;
      }
    }
  }
  for (i = 2; i < n; i++) {
    if (mark[i] == false) {
      a.push_back(i);
    }
  }
}
void prime(long long int n, vector<long long int>& a) {
  long long int i, j, low, high,
      limit = ((long long int)sqrt(n)) + (long long int)1;
  prime1(limit, a);
  low = limit;
  high = 2 * limit;
  while (low < n) {
    if (high >= n) {
      high = n;
    }
    bool mark[limit + 1];
    memset(mark, true, sizeof(mark));
    for (i = 0; i < a.size(); i++) {
      long long int lolimit = (low / a[i]) * a[i];
      if (lolimit < low) {
        lolimit += a[i];
      }
      for (j = lolimit; j < high; j += a[i]) {
        mark[j - low] = false;
      }
    }
    for (j = low; j < high; j++) {
      if (mark[j - low] == true) {
        a.push_back(j);
      }
    }
    low += limit;
    high += limit;
  }
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  long long int c, sum = 0, temp, n, k, i, ans, cnt = 0;
  cin >> n >> k;
  if ((8 * k) / n >= 20) {
    cout << 0;
    return 0;
  }
  k = (long long int)pow(2, (8 * k) / n);
  long long int a[n];
  vector<pair<long long int, long long int> > b;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  temp = a[0];
  for (i = 0; i < n; i++) {
    if (temp == a[i]) {
      cnt++;
    } else {
      b.push_back({temp, cnt});
      temp = a[i];
      cnt = 1;
    }
  }
  b.push_back({temp, cnt});
  sort(b.begin(), b.end());
  for (i = 0; i < k && i < b.size(); i++) {
    sum += b[i].second;
  }
  ans = sum;
  for (i = k; i < b.size(); i++) {
    sum += b[i].second - b[i - k].second;
    ans = max(sum, ans);
  }
  cout << n - ans;
}
