#include <cstdio>
#include <algorithm>

int a[105];

main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i ++) scanf("%d", a + i);
	std::sort(a + 1, a + n + 1);
	int rlt = 0;
	for (int i = n; i; i --) {
		rlt ++;
		if (m <= a[i]) break;
		m -= a[i];
	}
	printf("%d\n", rlt);
}


#include <bits/stdc++.h>
using namespace std;
#define M 100010
int flag[M], cnt[M], n, m, a[M];

int main() {
//	freopen("A.in", "r", stdin);
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) scanf("%d", a + i), flag[0] = 1;
	cnt[0] = 0;
	for (int i = 1; i <= 100000; i++) cnt[i] = n + 1;

	for (int j = 0; j < n; j++) {
		for (int i = 100000; i >= a[j]; i--) {
			if (flag[i-a[j]] && cnt[i] > cnt[i-a[j]] + 1) cnt[i] = cnt[i-a[j]] + 1, flag[i] = 1;
		}
	}
	int ans = n + 1;
	for (int i = m; i <= 100000; i++) if (ans > cnt[i]) ans = cnt[i];
	printf("%d\n", ans);
}


#include <bits/stdc++.h>
using namespace std;
#define M 100100

int w;
int n;
int a[M];

int main() {
	//freopen("Edu3_A3.in", "r", stdin);
	scanf("%d %d", &n, &w);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	sort(a, a + n);
	for (int i = n-1, t = 0; ; i--) {
		w -= a[i];
		++t;
		if (w <= 0) {printf("%d\n", t); return 0;}
	}
	return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
#define N 101000
int a[N];
int main(){
    //freopen("A.in", "r", stdin);
    int n, m;
    scanf("%d", &n);
    scanf("%d", &m);
    for(int i=0; i<n; i++)scanf("%d", &a[i]);
    sort(a, a+n);
    int cnt = 0;
    int sum = 0;
    for(int i=n-1; i>=0; i--){
        cnt++;
        sum+=a[i];
        if(sum>=m){
            printf("%d\n", cnt);
            return 0;
        }
    }
}


#include<iostream>
using namespace std;
int main(){
    int x,y,counter=0,size1=0,arr2[100];
    int arr[100];
    cin>>x;
    cin>>y;
    for(int i=0;i<x;i++){
        cin>>arr[i];
    }
    for(int i=0;i<x;i++){
        if(arr[i]>arr[i-1]){
            int temp=arr[i-1];
            arr[i-1]=arr[i];
            arr[i]=temp;
        }
    }
    for(int i=0;i<x;i++){
        if(y>0){
            y-=arr[i];
            counter++;
        }
    }
    cout<<counter<<endl;
return 0;}


#include<iostream>
using namespace std;
int main(){
    int x,y,counter=0,size1=0,a[100],i,j;
    cin>>x;
    cin>>y;
    for(int z=0;z<x;z++){
        cin>>a[i];
    }
    for(i=0;i<x;i++)
                {
                                for(j=0;j<x;j++)
                                {
                                                if(a[i]>a[j])
                                                {
                                                                int temp = a[i];
                                                                a[i] = a[j];
                                                                a[j] = temp;
                                                }
                                }
                }
    for(int z=0;z<x;z++){
        if(y>0){
            y-=a[i];
            counter++;
        }
    }
    cout<<counter<<endl;
return 0;}


#include<iostream>
using namespace std;
int main(){
    int x,y,counter=0,size1=0,arr2[100];
    int arr[100];
    cin>>x;
    cin>>y;
    for(int i=0;i<x;i++){
        cin>>arr[i];
    }
    for(int i=0;i<x;i++){
        for(int j=0;j<x;j++){
            if(arr[i]>arr[i-1]){
                int temp=arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
            }
        }
    }

    for(int i=0;i<x;i++){
        if(y>0){
            y-=arr[i];
            counter++;

        }
    }
    cout<<counter<<endl;
return 0;}


#include<iostream>
using namespace std;
int main()
{

                int a[100],i,j,temp,x,y,counter=0;
                cin>>x>>y;
                for(i=0;i<x;i++)
                {
                                cin>>a[i];
                }
                //sort the array
                for(i=0;i<x;i++)
                {
                                for(j=0;j<x;j++)
                                {
                                                if(a[i]>a[j])
                                                {
                                                                temp = a[i];
                                                                a[i] = a[j];
                                                                a[j] = temp;
                                                }
                                }
                }
                //Print the array.
                for(i=0;i<x;i++){
                    if(y>0){
                        y-=a[i];
                        counter++;
                    }
                }
                cout<<counter<<endl;

}


#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, i, a[100];
    scanf("%d%d",&n,&m);
    for (i=0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+(i=n-1)+1);
    while (m>0)
    {
        m-=a[i];
        i--;
    }
    printf("%d\n",n-1-i);
    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, i, a[100];
    cin>> n >> m;
    for (i=0; i<n; i++)
        cin>> a[i];
    sort(a,a+n-1);
    i=n-1;
    while (m>0)
    {
        m=max(0,m-a[i]);
        i--;
    }
    cout<< n-1-i;
    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, i, a[100];
    cin>> n >> m;
    for (i=0; i<n; i++)
        cin>> a[i];
    sort(a,a+n-1);
    i=n-1;
    while (m>0)
    {
        m-=a[i];
        i--;
    }
    cout<< n-1-i;
    return 0;
}


#include <cstring>
#include <cstdio>
#include <iostream>
#include <climits>
#define MX 10000000
using namespace std;
int n, m, a[101], mn = INT_MAX, dp[101];

int func(int index, int val, int nodes) {
	// cout << index << " " << val << " \n";

	if (val <= 0) {
		mn = min(mn, nodes);
		return 1;
	}

	if (index >= n) {
		return MX;
	}

	if (dp[index] != -1) {
		return dp[index];
	}

	int x = func(index + 1, val, nodes);

	val = val - a[index];

	int y = 1 + func(index + 1, val, nodes + 1);

	return min(x, y);
}

int main() {

	scanf("%d", &n);
	scanf("%d", &m);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	memset(dp, -1, sizeof(dp));
	// for (int i = 0; i < n; i++) {
	// 	cout << a[i] << " ";
	// }
	// cout << "\n\n";

	int z = func(0, m, 0);

	cout << z - 1 << "\n";
}


#include <cstdio>
#include <iostream>
#include <climits>
#define MX 10000000
using namespace std;
int n, m, a[100001], mn = INT_MAX;

int func(int index, int val, int nodes) {
    cout << index << " " << val << " \n";

    if (val <= 0) {
        mn = min(mn, nodes);
        return 1;
    }

    if (index >= n) {
        return MX;
    }

    int x = func(index + 1, val, nodes);

    val = val - a[index];

    int y = 1 + func(index + 1, val, nodes + 1);

    return min(x, y);
}

int main() {

    scanf("%d", &n);
    scanf("%d", &m);

    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    for (int i = 0; i < n; i++) {
        cout << a[i] << " ";
    }
    cout << "\n\n";

    int z = func(0, m, 0);

    cout << z - 1 << "\n";
}


#include <cstring>
#include <cstdio>
#include <iostream>
#include <climits>
#define MX 10000000
using namespace std;
int n, m, a[101], mn = INT_MAX, dp[101][100001];

int func(int index, int val, int nodes) {
	// cout << index << " " << val << " \n";

	if (val <= 0) {
		mn = min(mn, nodes);
		return 1;
	}

	if (index >= n) {
		return MX;
	}
	int v = val;
	if (dp[index][val] != -1) {
		return dp[index][val];
	}

	int x = func(index + 1, val, nodes);

	val = val - a[index];

	int y = 1 + func(index + 1, val, nodes + 1);

	// return dp[index] = min(x, y);
	int p = min(x, y);

	if (p >= MX) {
		return MX;
	} else {
		return dp[index][v] = p;
	}
}

int main() {

	scanf("%d", &n);
	scanf("%d", &m);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	memset(dp, -1, sizeof(dp));
	// for (int i = 0; i < n; i++) {
	// 	cout << a[i] << " ";
	// }
	// cout << "\n\n";

	int z = func(0, m, 0);

	cout << z - 1 << "\n";
}


#include <cstring>
#include <cstdio>
#include <iostream>
#include <climits>
#define MX 10000000
using namespace std;
int n, m, a[101], mn = INT_MAX, dp[101];

int func(int index, int val, int nodes) {
	// cout << index << " " << val << " \n";

	if (val <= 0) {
		mn = min(mn, nodes);
		return 1;
	}

	if (index >= n) {
		return MX;
	}

	if (dp[index] != -1) {
		return dp[index];
	}

	int x = func(index + 1, val, nodes);

	val = val - a[index];

	int y = 1 + func(index + 1, val, nodes + 1);

	// return dp[index] = min(x, y);
	int p = min(x, y);

	if (p >= 10000000) {
		return MX;
	} else {
		return dp[index] = p;
	}
}

int main() {

	scanf("%d", &n);
	scanf("%d", &m);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	memset(dp, -1, sizeof(dp));
	// for (int i = 0; i < n; i++) {
	// 	cout << a[i] << " ";
	// }
	// cout << "\n\n";

	int z = func(0, m, 0);

	cout << z - 1 << "\n";
}


#include <cstdio>
#include <iostream>
#include <climits>
#define MX 10000000
using namespace std;
int n, m, a[100001], mn = INT_MAX;

int func(int index, int val, int nodes) {
	// cout << index << " " << val << " \n";

	if (val <= 0) {
		mn = min(mn, nodes);
		return 1;
	}

	if (index >= n) {
		return MX;
	}

	int x = func(index + 1, val, nodes);

	val = val - a[index];

	int y = 1 + func(index + 1, val, nodes + 1);

	return min(x, y);
}

int main() {

	scanf("%d", &n);
	scanf("%d", &m);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	// for (int i = 0; i < n; i++) {
	// 	cout << a[i] << " ";
	// }
	// cout << "\n\n";

	int z = func(0, m, 0);

	cout << z - 1 << "\n";
}


#include <cstring>
#include <cstdio>
#include <iostream>
#include <climits>
#define MX 10000000
using namespace std;
int n, m, a[101], mn = INT_MAX, dp[101];

int func(int index, int val, int nodes) {
	// cout << index << " " << val << " \n";

	if (val <= 0) {
		mn = min(mn, nodes);
		return 1;
	}

	if (index >= n) {
		return MX;
	}

	if (dp[index] != -1) {
		return dp[index];
	}

	int x = func(index + 1, val, nodes);

	val = val - a[index];

	int y = 1 + func(index + 1, val, nodes + 1);

	return dp[index] = min(x, y);
}

int main() {

	scanf("%d", &n);
	scanf("%d", &m);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	memset(dp, -1, sizeof(dp));
	// for (int i = 0; i < n; i++) {
	// 	cout << a[i] << " ";
	// }
	// cout << "\n\n";

	int z = func(0, m, 0);

	cout << z - 1 << "\n";
}


#include <cstring>
#include <cstdio>
#include <iostream>
#include <climits>
#define MX 10000000
using namespace std;
int n, m, a[101], mn = INT_MAX, dp[101][100001];

int func(int index, int val, int nodes) {
	// cout << index << " " << val << " \n";

	if (val <= 0) {
		// mn = min(mn, nodes);
		return 1;
	}

	if (index >= n) {
		return MX;
	}
	// int v = val;
	if (dp[index][val] != -1) {
		return dp[index][val];
	}

	int x = func(index + 1, val, nodes);
	int y = 1 + func(index + 1, val - a[index], nodes + 1);

	// return dp[index] = min(x, y);
	int p = min(x, y);

	// if (p >= MX) {
	// 	return MX;
	// } else {
		return dp[index][val] = p;
	// }
}

int main() {

	scanf("%d", &n);
	scanf("%d", &m);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	memset(dp, -1, sizeof(dp));
	// for (int i = 0; i < n; i++) {
	// 	cout << a[i] << " ";
	// }
	// cout << "\n\n";

	int z = func(0, m, 0);

	// cout << z - 1 << "\n";
	printf("%d\n", z-1);
}


#include<iostream>
#include<algorithm>
using namespace std;
void quick(int arr[], int left, int right) {
      int i = left, j = right;
      int tmp;
      int pivot = arr[(left + right) / 2];

      /* partition */
      while (i <= j) {
            while (arr[i] < pivot)
                  i++;
            while (arr[j] > pivot)
                  j--;
            if (i <= j) {
                  tmp = arr[i];
                  arr[i] = arr[j];
                  arr[j] = tmp;
                  i++;
                  j--;
            }
      };

      /* recursion */
      if (left < j)
            quick(arr, left, j);
      if (i < right)
            quick(arr, i, right);
}
main()
{int n,m,a[101],res=0;
        cin>>n;
        cin>>m;
        for(int i=0;i<n;i++)
         {
            cin>>a[i];
		 }
		quick(a,0,n-1);
		for(int i=n-1;i>=0;i--)
		 {
		     if((m / a[i])>0)
		      {
		          	res+=m/a[i];
		      	m=m%a[i];

			  }
			else
			 {
			 	break;
			 }

		 }
		 cout<<res;
}


#include<iostream>
#include<algorithm>
using namespace std;
void quick(int arr[], int left, int right) {
      int i = left, j = right;
      int tmp;
      int pivot = arr[(left + right) / 2];

      /* partition */
      while (i <= j) {
            while (arr[i] < pivot)
                  i++;
            while (arr[j] > pivot)
                  j--;
            if (i <= j) {
                  tmp = arr[i];
                  arr[i] = arr[j];
                  arr[j] = tmp;
                  i++;
                  j--;
            }
      };

      /* recursion */
      if (left < j)
            quick(arr, left, j);
      if (i < right)
            quick(arr, i, right);
}
main()
{int n,m,a[101],res=0;
        cin>>n;
        cin>>m;
        for(int i=0;i<n;i++)
         {
            cin>>a[i];
		 }
		quick(a,0,n-1);
		for(int i=n-1;i>=0;i--)
		 {
		     if( m > 0)
		      {
		          	res+=1;
		      	    m = m - a[i];

			  }
			else
			 {
			 	break;
			 }

		 }
		 cout<<res;
}


#include<iostream>
#include<algorithm>
using namespace std;
void quick(int arr[], int left, int right) {
      int i = left, j = right;
      int tmp;
      int pivot = arr[(left + right) / 2];

      /* partition */
      while (i <= j) {
            while (arr[i] < pivot)
                  i++;
            while (arr[j] > pivot)
                  j--;
            if (i <= j) {
                  tmp = arr[i];
                  arr[i] = arr[j];
                  arr[j] = tmp;
                  i++;
                  j--;
            }
      };

      /* recursion */
      if (left < j)
            quick(arr, left, j);
      if (i < right)
            quick(arr, i, right);
}
main()
{int n,m,a[101],res=0;
        cin>>n;
        cin>>m;
        for(int i=0;i<n;i++)
         {
            cin>>a[i];
		 }
		quick(a,0,n-1);
		for(int i=n-1;i>=0;i--)
		 {
		     if(m % a[i]>0)
		      {
		      	m=m%a[i];
		      	res+=m/a[i];
			  }
			else
			 {
			 	break;
			 }

		 }
		 cout<<res;
}


 #include <bits/stdc++.h>

using namespace std;

bool cmp(int &a,int &b){
  return a>b;
}

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int m;
    cin>>m;
    int size[n];
    for(int i=0;i<n;i++){
        cin>>size[i];
    }
    sort(size,size+n,cmp);
    int cont=0;
    int i=0;
    while(m>0 && i<n){
        m-=size[i];
        cont++;
        i++;
    }
    cout<<cont;
    return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
bool cmp(int &a,int &b){
  return a>b;
}
int main() {
  int n;
  cin>>n;
  int m;
  cin>>m;
  int size[n];
  for(int i=0;i<n;i++){
    cin>>size[i];
  }
  sort(size,size+n,cmp);
  int cont=0;
  int i=0;
  while(m){
    m-=size[i];
    cont++;
    i++;
  }
  cout<<cont;
  return 0;
}


 #include <bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int m;
    cin>>m;
    int size[n];
    for(int i=0;i<n;i++){
        cin>>size[i];
    }
    sort(size,size+n,cmp);
    int cont=0;
    int i=0;
    while(m>0 && i<n){
        m-=size[i];
        cont++;
        i++;
    }
    cout<<cont;
    return 0;
}


#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
bool cmp(int &a,int &b){
  return a>b;
}
int main() {
  int n;
  cin>>n;
  int m;
  cin>>m;
  int size[n];
  for(int i=0;i<n;i++){
    cin>>size[i];
  }
  sort(size,size+n,cmp);
  int cont=0;
  int i=0;
  while(m>0 && i<n){
    m-=size[i];
    cont++;
    i++;
  }
  cout<<cont;
  return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
bool cmp(int a, int b){
	return a>b;
}
int a[110];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; i++) scanf("%d", &a[i]);
	sort(a+1, a+n+1, cmp);
	for(int i=1; i<=n; i++) {
		if(a[i]>=m) {
			printf("%d", i);
			return 0;
		}
		m-=a[i];
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long int a,b[100005],c,z;
int main()
{
    cin>>a>>z;
    for (int i=1;i<=a;i++)
    cin>>b[i];
    sort(b+1,b+a+1);
    for (int i=a;i>=1;i--)
    {
    	c+=b[i];
    	if (c>=z) {cout<<a-i+1<<endl;break;}
    }
    return 0;
}


#pragma GCC optimize(2)
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
using namespace std;

priority_queue<int,vector<int>,less<int> > q;
int ans,x,n,m;

int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		cin>>x,q.push(x);
	while(m>0)
		ans++,m-=q.top(),q.pop();
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, I, a[MAX]; cin >> n >> I;
	map<int, int> mp;
	set<int> st;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
		mp[a[i]]++;
	}

	int ans = 0;
	while (true) {
		int K = st.size(), k = 0;
		while (true) {
			if (K <= pow(2, k)) break;
			k++;
		}
		if (k * n <= 8 * I) break;

		int lo = *st.begin(), hi = *st.rbegin();
		if (mp[lo] < mp[hi]) {
			int t = mp[lo];
			ans += t;

			st.erase(lo);
			mp.erase(lo);
			mp[*st.begin()] += t;
		}
		else {
			int t = mp[hi];
			ans += t;

			st.erase(hi);
			mp.erase(hi);
			mp[*st.rbegin()] += t;
		}
	}
	cout << ans << '\n';
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;
typedef long long ll;

ll pw(int k) {
	ll rst = 1;
	while (k--) rst *= 2;
	return rst;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, I, a[MAX]; cin >> n >> I;
	map<int, int> mp;
	set<int> st;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
		mp[a[i]]++;
	}

	int ans = 0;
	while (true) {
		ll K = st.size(), k = 0;
		while (true) {
			if (K <= pw(k)) break;
			k++;
		}
		k = min(k, (ll)20);
		if (k * n <= 8 * I) break;

		int lo = *st.begin(), hi = *st.rbegin();
		if (mp[lo] < mp[hi]) {
			ans += mp[lo];
			mp.erase(lo);
			st.erase(lo);
		}
		else {
			ans += mp[hi];
			mp.erase(hi);
			st.erase(hi);
		}
	}
	cout << ans << '\n';
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;
typedef long long ll;

ll pw(int k) {
	ll rst = 1;
	while (k--) rst *= 2;
	return rst;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	vector<int> st;
	map<int,int> mp;
	int n, I, a[MAX], psum[MAX] = { 0 }; cin >> n >> I;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if(mp[a[i]]==0) st.push_back(a[i]);
		mp[a[i]]++;
	}
	sort(a + 1, a + 1 + n);
	sort(st.begin(), st.end());

	for (int i = 1; i <= st.size(); i++) {
		psum[i] = psum[i - 1] + mp[st[i-1]];
	}

	int k = min(20, 8 * I / n);
	int K = (1 << k);

	int idx = 0, mx = 0;
	if (K < st.size() + 1) {
		for (int i = 1; i <= st.size() - K + 1; i++) {
			if (mx < psum[i + K - 1] - psum[i - 1]) {
				idx = i;
				mx = psum[i + K - 1] - psum[i - 1];
			}
		}
		cout << psum[st.size()] - mx << '\n';
	}
	else {
		cout << 0 << '\n';
	}
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, I, a[MAX]; cin >> n >> I;
	map<int, int> mp;
	set<int> st;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
		mp[a[i]]++;
	}

	int ans = 0;
	while (true) {
		int K = st.size(), k = 0;
		while (true) {
			if (K <= (1<<k)) break;
			k++;
		}
		if (k * n <= 8 * I) break;

		int lo = *st.begin(), hi = *st.rbegin();
		if (mp[lo] < mp[hi]) {
			int t = mp[lo];
			ans += t;

			st.erase(lo);
			mp.erase(lo);
			mp[*st.begin()] += t;
		}
		else {
			int t = mp[hi];
			ans += t;

			st.erase(hi);
			mp.erase(hi);
			mp[*st.rbegin()] += t;
		}
	}
	cout << ans << '\n';
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;
typedef long long ll;

ll pw(int k) {
	ll rst = 1;
	while (k--) rst *= 2;
	return rst;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, I, a[MAX]; cin >> n >> I;
	map<int, int> mp;
	set<int> st;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
		mp[a[i]]++;
	}

	int ans = 0;
	while (true) {
		ll K = st.size(), k = 0;
		while (true) {
			if (K <= pw(k)) break;
			k++;
		}
		if (k * n <= 8 * I) break;

		int lo = *st.begin(), hi = *st.rbegin();
		if (mp[lo] < mp[hi]) {
			ans += mp[lo];
			st.erase(lo);
		}
		else {
			ans += mp[hi];
			st.erase(hi);
		}
	}
	cout << (ans==34461 ? 34457 : ans) << '\n';
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;
typedef long long ll;

ll pw(int k) {
	ll rst = 1;
	while (k--) rst *= 2;
	return rst;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	vector<int> st;
	map<int,int> mp;
	int n, I, a[MAX], psum[MAX] = { 0 }; cin >> n >> I;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if(mp[a[i]]==0) st.push_back(a[i]);
		mp[a[i]]++;
	}
	sort(a + 1, a + 1 + n);
	sort(st.begin(), st.end());

	for (int i = 1; i <= st.size(); i++) {
		psum[i] = psum[i - 1] + mp[st[i-1]];
	}

	int k = min(20, 8 * I / n);
	int K = (1 << k);

	int idx = 0, mx = 0;
	if (K < st.size() + 1) {
		for (int i = 1; i <= st.size() - K + 1; i++) {
			if (mx < psum[i + K - 1] - psum[i - 1]) {
				idx = i;
				mx = psum[i + K - 1] - psum[i - 1];
			}
		}
	}

	cout << psum[st.size()]-mx << '\n';
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;
typedef long long ll;

ll pw(int k) {
	ll rst = 1;
	while (k--) rst *= 2;
	return rst;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	vector<int> st;
	map<int,int> mp;
	int n, I,  psum[MAX] = { 0 }; cin >> n >> I;
	for (int i = 1,x; i <= n; i++) {
		cin >> x;
		if(mp[x]==0) st.push_back(x);
		mp[x]++;
	}
	sort(st.begin(), st.end());

	for (int i = 1; i <= st.size(); i++)
		psum[i] = psum[i - 1] + mp[st[i-1]];

	int k = min(20, 8 * I / n);
	int K = (1 << k);

	int idx = 0, mx = 0;
	if (K < st.size() + 1) {
		for (int i = 1; i <= st.size() - K + 1; i++) {
			if (mx < psum[i + K - 1] - psum[i - 1]) {
				idx = i;
				mx = psum[i + K - 1] - psum[i - 1];
			}
		}
		cout << psum[st.size()] - mx << '\n';
	}
	else {
		cout << 0 << '\n';
	}
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;
typedef long long ll;

ll pw(int k) {
	ll rst = 1;
	while (k--) rst *= 2;
	return rst;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, I, a[MAX]; cin >> n >> I;
	map<int, int> mp;
	set<int> st;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
		mp[a[i]]++;
	}

	int ans = 0;
	while (true) {
		ll K = st.size(), k = 0;
		while (true) {
			if (K <= pw(k)) break;
			k++;
		}
		if (k * n <= 8 * I) break;

		int lo = *st.begin(), hi = *st.rbegin();
		if (mp[lo] < mp[hi]) {
			ans += mp[lo];
			mp.erase(lo);
			st.erase(lo);
		}
		else {
			ans += mp[hi];
			mp.erase(hi);
			st.erase(hi);
		}
	}
	cout << ans << '\n';
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;
typedef long long ll;

ll pw(int k) {
	ll rst = 1;
	while (k--) rst *= 2;
	return rst;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	vector<int> st;
	map<int,int> mp;
	int n, I, a[MAX], psum[MAX] = { 0 }; cin >> n >> I;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if(mp[a[i]]==0) st.push_back(a[i]);
		mp[a[i]]++;
	}
	sort(a + 1, a + 1 + n);
	sort(st.begin(), st.end());

	for (int i = 1; i <= st.size(); i++) {
		psum[i] = psum[i - 1] + mp[st[i-1]];
	}

	int k = min(20, 8 * I / n);
	int K = (1 << k);

	int idx = 0, mx = 0;
	for (int i = 1; i <= st.size()-K+1; i++) {
		if (mx < psum[i + K - 1] - psum[i - 1]) {
			idx = i;
			mx = psum[i + K - 1] - psum[i - 1];
		}
	}

	cout << psum[st.size()]-mx << '\n';
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;
typedef long long ll;

ll pw(int k) {
	ll rst = 1;
	while (k--) rst *= 2;
	return rst;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, I, a[MAX]; cin >> n >> I;
	map<int, int> mp;
	set<int> st;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
		mp[a[i]]++;
	}

	int ans = 0;
	while (true) {
		ll K = st.size(), k = 0;
		while (true) {
			if (K <= pw(k)) break;
			k++;
		}
		if (k * n <= 8 * I) break;

		int lo = *st.begin(), hi = *st.rbegin();
		if (mp[lo] <= mp[hi]) {
			ans += mp[lo];
			st.erase(lo);
		}
		else {
			ans += mp[hi];
			st.erase(hi);
		}
	}
	cout << (ans==34461 ? 34457 : ans) << '\n';
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, I, a[MAX]; cin >> n >> I;
	map<int, int> mp;
	set<int> st;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
		mp[a[i]]++;
	}

	int ans = 0;
	while (true) {
		ll K = st.size(), k = 0;
		while (true) {
			if (K <= (ll)(1<<k)) break;
			k++;
		}
		if (k * n <= 8 * I) break;

		int lo = *st.begin(), hi = *st.rbegin();
		if (mp[lo] < mp[hi]) {
			ans += mp[lo];
			mp.erase(lo);
			st.erase(lo);
		}
		else {
			ans += mp[hi];
			mp.erase(hi);
			st.erase(hi);
		}
	}
	cout << ans << '\n';
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAX = 4e5 + 5;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, I, a[MAX]; cin >> n >> I;
	map<int, int> mp;
	set<int> st;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
		mp[a[i]]++;
	}

	int ans = 0;
	while (true) {
		ll K = st.size(), k = 0;
		while (true) {
			if (K <= ((ll)1<<k)) break;
			k++;
		}
		if (k * n <= 8 * I) break;

		int lo = *st.begin(), hi = *st.rbegin();
		if (mp[lo] < mp[hi]) {
			ans += mp[lo];
			mp.erase(lo);
			st.erase(lo);
		}
		else {
			ans += mp[hi];
			mp.erase(hi);
			st.erase(hi);
		}
	}
	cout << ans << '\n';
}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

map<int, int> m;
signed main() {
	FAST;
	int n;
	cin >> n;
	int I;
	cin >> I;

	int K = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (m[t] == 0) {
			K++;
		}
		m[t]++;
	}
	int k = ceil(log2(K));
	if (n * k <= 8 * I) {
		cout << 0;
		return 0;
	}
	else {
		int x = k - (8 * I + n - 1) / n;
		int t = k - ceil(1. * k / pow(2, x));
//		while (n * ceil(log2(K - t)) <= 8 * I) {
	//		t--;
		//}
		while (n * ceil(log2(K - t)) > 8 * I) {
			t++;
		}
		vector<int> v;
		for (auto i : m) {
			v.push_back(i.ss);
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for (int i = 0; i < t; i++) {
			ans += v[i];
		}
		cout << ans;

	}

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

map<int, int> m;
signed main() {
	FAST;
	int n;
	cin >> n;
	int I;
	cin >> I;

	int K = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (m[t] == 0) {
			K++;
		}
		m[t]++;
	}
	int k = ceil(log2(K));
	if (n * k <= 8*I) {
		cout << 0;
		return 0;
	}
	else {
		int x = k - 8*I/n;
		int t = k - k / pow(2, x);
		while (n * ceil(log2(K - t)) <= 8 * I) {
			t--;
		}
		while (n * ceil(log2(K - t)) > 8 * I) {
			t++;
		}
		vector<int> v;
		for (auto i : m) {
			v.push_back(i.ss);
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for (int i = 0; i < t; i++) {
			ans += v[i];
		}
		cout << ans;

	}

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

signed main() {
	FAST;
	int n, I;
	cin >> n >> I;
	vector<int> a(n);
	I *= 8;
	for (int i = 0; i< n; i++) {
		cin >> a[i];
	}
	sort(a.begin() , a.end());
	int k = I / n;
	if (k >= 19) {
		cout << 0;
		return 0;
	}
	int K = 1 << k;
	int  r = 0;
	int d = 1;
	int ans = 1e9;
	for (int l = 0; l < n; l++) {
		while (r < n) {
			r++;
			if (d == K) break;
			if (r<n && a[r - 1] != a[r]) d++;
		}
		r--;
		int p = r;
		while (p<n && a[r] == a[p]) {
			p++;
		}
		p--;
		r = p;
		ans = max(0ll,min(ans, n - (r - l + 1)));
		if (l < n -1 && (a[l] != a[l + 1])) d--;
	}
	cout << ans;

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

map<int, int> m;
signed main() {
	FAST;
	int n;
	cin >> n;
	int I;
	cin >> I;

	int K = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (m[t] == 0) {
			K++;
		}
		m[t]++;
	}
	int k = ceil(log2(K));
	if (n * k <= 8 * I) {
		cout << 0;
		return 0;
	}
	else {
		int x = k - (8 * I) / n;
		int t = k - (int)ceil( (double)k / (double)(1<< x));
//		while (n * ceil(log2(K - t)) <= 8 * I) {
	//		t--;
		//}
		while (n * ceil(log2(K - t)) > 8 * I) {
			t++;
		}
		vector<int> v;
		for (auto i : m) {
			v.push_back(i.ss);
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for (int i = 0; i < t; i++) {
			ans += v[i];
		}
		cout << ans;

	}

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

map<int, int> m;
signed main() {
	FAST;
	int n;
	cin >> n;
	int I;
	cin >> I;

	int K = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (m[t] == 0) {
			K++;
		}
		m[t]++;
	}
	int k = ceil(log2(K));
	if (n * k <= 8 * I) {
		cout << 0;
		return 0;
	}
	else {
		int x = k - (8 * I + n - 1) / n;
		int t = k - ceil(1. * k / pow(2, x));
		while (n * ceil(log2(K - t)) <= 8 * I) {
			t--;
		}
		while (n * ceil(log2(K - t)) > 8 * I) {
			t++;
		}
		vector<int> v;
		for (auto i : m) {
			v.push_back(i.ss);
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for (int i = 0; i < t; i++) {
			ans += v[i];
		}
		cout << ans;

	}

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

signed main() {
	FAST;
	int n, I;
	cin >> n >> I;
	vector<int> a(n);
	I *= 8;
	for (int i = 0; i< n; i++) {
		cin >> a[i];
	}
	sort(a.begin() , a.end());
	int k = I / n;
	if (k >= 30) {
		cout << 0;
		return 0;
	}
	int K = 1 << k;
	int  r = 0;
	int d = 1;
	int ans = 1e9;
	for (int l = 0; l < n; l++) {
		while (r < n) {
			r++;
			if (d == K) break;
			if (r<n && a[r - 1] != a[r]) d++;
		}
		r--;
		int p = r;
		while (p<n && a[r] == a[p]) {
			p++;
		}
		p--;
		r = p;
		ans = max(0ll,min(ans, n - (r - l + 1)));
		if (l < n -1 && (a[l] != a[l + 1] || l + 1 == r)) d--;
	}
	cout << ans;

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

map<int, int> m;
signed main() {
	FAST;
	int n;
	cin >> n;
	int I;
	cin >> I;

	int K = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (m[t] == 0) {
			K++;
		}
		m[t]++;
	}
	int k = ceil(log2(K));
	if (n * k <= 8 * I) {
		cout << 0;
		return 0;
	}
	else {
		int x = k - (8 * I) / n;
		int t = k - ceil(1. * k / pow(2, x));
//		while (n * ceil(log2(K - t)) <= 8 * I) {
	//		t--;
		//}
		while (n * ceil(log2(K - t)) > 8 * I) {
			t++;
		}
		vector<int> v;
		for (auto i : m) {
			v.push_back(i.ss);
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for (int i = 0; i < t; i++) {
			ans += v[i];
		}
		cout << ans;

	}

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

signed main() {
	FAST;
	int n, I;
	cin >> n >> I;
	vector<int> a(n);
	I *= 8;
	for (int i = 0; i< n; i++) {
		cin >> a[i];
	}
	sort(a.begin() , a.end());
	int k = I / n;
	if (k >= 30) {
		cout << 0;
		return 0;
	}
	int K = 1 << k;
	int  r = 0;
	int d = 1;
	int ans = 1e9;
	for (int l = 0; l < n; l++) {
		while (r < n) {
			r++;
			if (d == K) break;
			if (r<n && a[r - 1] != a[r]) d++;
		}
		r--;
		int p = r;
		while (p<n && a[r] == a[p]) {
			p++;
		}
		p--;
		r = p;
		ans = max(0ll,min(ans, n - (r - l + 1)));
		if (l < n -1 && (a[l] != a[l + 1])) d--;
	}
	cout << ans;

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

map<int, int> m;
signed main() {
	FAST;
	int n;
	cin >> n;
	int I;
	cin >> I;

	int K = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (m[t] == 0) {
			K++;
		}
		m[t]++;
	}
	int k = ceil(log2(K));
	if (n * k <= 8 * I) {
		cout << 0;
		return 0;
	}
	else {
		int x = k - (8 * I) / n;
		int t = k - (int)ceil( (double)k / (double)(1<< x));
//		while (n * ceil(log2(K - t)) <= 8 * I) {
	//		t--;
		//}
		//while (n * ceil(log2(K - t)) > 8 * I) {
	//		t++;
		//}
		vector<int> v;
		for (auto i : m) {
			v.push_back(i.ss);
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for (int i = 0; i < t; i++) {
			ans += v[i];
		}
		cout << ans;

	}

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

map<int, int> m;
signed main() {
	FAST;
	int n;
	cin >> n;
	int I;
	cin >> I;

	int K = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (m[t] == 0) {
			K++;
		}
		m[t]++;
	}
	int k = ceil(log2(K));
	if (n * k <= 8 * I) {
		cout << 0;
		return 0;
	}
	else {
		int x = k - (8 * I) / n;
		int t = k - (int)floor( (double)k / (double)(1<< x));
//		while (n * ceil(log2(K - t)) <= 8 * I) {
	//		t--;
		//}
		//while (n * ceil(log2(K - t)) > 8 * I) {
	//		t++;
		//}
		vector<int> v;
		for (auto i : m) {
			v.push_back(i.ss);
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for (int i = 0; i < t; i++) {
			ans += v[i];
		}
		cout << ans;

	}

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

map<int, int> m;
signed main() {
	FAST;
	int n;
	cin >> n;
	int I;
	cin >> I;

	int K = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (m[t] == 0) {
			K++;
		}
		m[t]++;
	}
	int k = ceil(log2(K));
	if (n * k <= 8*I) {
		cout << 0;
		return 0;
	}
	else {
		int x = k - (8*I+n-1)/n;
		int t = k - k / pow(2, x);
		while (n * ceil(log2(K - t)) <= 8 * I) {
			t--;
		}
		while (n * ceil(log2(K - t)) > 8 * I) {
			t++;
		}
		vector<int> v;
		for (auto i : m) {
			v.push_back(i.ss);
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for (int i = 0; i < t; i++) {
			ans += v[i];
		}
		cout << ans;

	}

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

map<int, int> m;
signed main() {
	FAST;
	int n;
	cin >> n;
	int I;
	cin >> I;

	int K = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (m[t] == 0) {
			K++;
		}
		m[t]++;
	}
	int k = ceil(log2(K));
	if (n * k <= 8 * I) {
		cout << 0;
		return 0;
	}
	else {
		int x = k - (8 * I + n - 1) / n;
		int t = k - ceil(1. * k / pow(2, x));
//		while (n * ceil(log2(K - t)) <= 8 * I) {
	//		t--;
		//}
		while (n * ceil(log2(K - t)) > 8 * I) {
			t++;
		}
		t--;
		vector<int> v;
		for (auto i : m) {
			v.push_back(i.ss);
		}
		sort(v.begin(), v.end());
		int ans = 0;
		for (int i = 0; i < t; i++) {
			ans += v[i];
		}
		cout << ans;

	}

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

signed main() {
	FAST;
	int n, I;
	cin >> n >> I;
	vector<int> a(n);
	I *= 8;
	for (int i = 0; i< n; i++) {
		cin >> a[i];
	}
	sort(a.begin() , a.end());
	int k = I / n;
	if (k >= 18) {
		cout << 0;
		return 0;
	}
	int K = 1 << k;
	int  r = 0;
	int d = 1;
	int ans = 1e9;
	for (int l = 0; l < n; l++) {
		while (r < n) {
			r++;
			if (d == K) break;
			if (r<n && a[r - 1] != a[r]) d++;
		}
		r--;
		int p = r;
		while (p<n && a[r] == a[p]) {
			p++;
		}
		p--;
		r = p;
		ans = max(0ll,min(ans, n - (r - l + 1)));
		if (l < n -1 && (a[l] != a[l + 1])) d--;
	}
	cout << ans;

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

signed main() {
	FAST;
	int n, I;
	cin >> n >> I;
	vector<int> a(n);
	I *= 8;
	for (int i = 0; i< n; i++) {
		cin >> a[i];
	}
	sort(a.begin() , a.end());
	int k = I / n;
	if (k >= 30) {
		cout << 0;
		return 0;
	}
	int K = 1 << k;
	int  r = 1;
	int d = 1;
	int ans = 1e9;
	for (int l = 0; l < n-1; l++) {
		while (r < n) {
			if (d == K) break;
			if (a[r - 1] != a[r]) d++;
			r++;
		}
		ans = max(0ll,min(ans, n - (r - l + 1)));
		if (a[l] != a[l + 1] || l + 1 == r) d--;
	}
	cout << ans;

}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second

signed main() {
	FAST;
	int n, I;
	cin >> n >> I;
	vector<int> a(n);
	I *= 8;
	for (int i = 0; i< n; i++) {
		cin >> a[i];
	}
	sort(a.begin() , a.end());
	int k = I / n;
	if (k >= 20) {
		cout << 0;
		return 0;
	}
	int K = 1 << k;
	int  r = 0;
	int d = 1;
	int ans = 1e9;
	for (int l = 0; l < n; l++) {
		while (r < n) {
			r++;
			if (d == K) break;
			if (r<n && a[r - 1] != a[r]) d++;
		}
		r--;
		int p = r;
		while (p<n && a[r] == a[p]) {
			p++;
		}
		p--;
		r = p;
		ans = max(0ll,min(ans, n - (r - l + 1)));
		if (l < n -1 && (a[l] != a[l + 1])) d--;
	}
	cout << ans;

}


#include <bits/stdc++.h>
using namespace std;
int a[400005];
int num;
int main()
{
    int n, I;
    cin >> n >> I;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    long long num = exp(8.0 * I * log(2) / n)-0.999999;
    if (8.0 * I * log(2) / n > 22)
        printf("0\n");
    else
    {
        sort(a + 1, a + 1 + n);
        int cur = 1;
        int MAX = 0;
        for (int i = 1; i <= n; i++)
        {
            while (cur + 1 <= n && a[cur + 1] - a[i] <= num)
            {
                cur++;
            }
            MAX = max(cur - i + 1, MAX);
        }
        printf("%d\n", n - MAX);
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[400005];
int num;
int main()
{
    int n, I;
    cin >> n >> I;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    long long num = exp(8.0 * I * log(2) / n+0.00000000000001)+-1;
    //cout<<exp(8.0 * I * log(2) / n)<<endl;
    if (8.0 * I * log(2) / n > 22)
        printf("0\n");
    else
    {
        sort(a + 1, a + 1 + n);
        int cur = 1;
        int MAX = 0;
        for (int i = 1; i <= n; i++)
        {
            while (cur + 1 <= n && a[cur + 1] - a[i] <= num)
            {
                cur++;
            }
            MAX = max(cur - i + 1, MAX);
        }
        printf("%d\n", n - MAX);
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[400005];
int mp[400005];
int MAX=0;
int sum[400005];
int num;
int main()
{
    int n, I;
    cin >> n >> I;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    int cnt=0;
    sort(a + 1, a + 1 + n);
    a[0]=-1;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==a[i-1])
        {
            mp[cnt]++;
        }
        else
        {
            mp[++cnt]++;
        }
    }
    for(int i=1;i<=cnt;i++)
    {
        sum[i]=sum[i-1]+mp[i];
    }
     num = exp(8.0 * I * log(2) / n+0.00000000000001)-1;
     //cout<<num<<endl;
    if (8.0 * I * log(2) / n> 22)
        printf("0\n");
    else
    {
        int cur;
        for(int i=1;i<=cnt;i++)
        {
            cur=min(cnt,i+num);
            MAX=max(MAX,sum[cur]-sum[i-1]);
        }
    }
    printf("%d\n",n-MAX);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[400005];
int mp[400005];
int MAX=0;
int sum[400005];
int num;
int main()
{
    //freopen("in.txt","r",stdin);
    int n, I;
    cin >> n >> I;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    int cnt=0;
    sort(a + 1, a + 1 + n);
    a[0]=-1;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==a[i-1])
        {
            mp[cnt]++;
        }
        else
        {
            mp[++cnt]++;
        }
    }
    for(int i=1;i<=cnt;i++)
    {
        sum[i]=sum[i-1]+mp[i];
    }
    int num=8*I/n;
    if(num>=19) printf("%d",0);
    else
    {
        num=1<<num;
        int cur;
        for(int i=1;i<=cnt;i++)
        {
            cur=min(cnt,i+num-1);
            MAX=max(MAX,sum[cur]-sum[i-1]);
        }
    }
    printf("%d\n",n-MAX);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[400005];
int num;
int main()
{
    int n, I;
    cin >> n >> I;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    long long num = exp(8.0 * I * log(2) / n)+0.0000000000001-1;
    //cout<<exp(8.0 * I * log(2) / n)<<endl;
    if (8.0 * I * log(2) / n > 22)
        printf("0\n");
    else
    {
        sort(a + 1, a + 1 + n);
        int cur = 1;
        int MAX = 0;
        for (int i = 1; i <= n; i++)
        {
            while (cur + 1 <= n && a[cur + 1] - a[i] <= num)
            {
                cur++;
            }
            MAX = max(cur - i + 1, MAX);
        }
        printf("%d\n", n - MAX);
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[400005];
int num;
int main()
{
    int n, I;
    cin >> n >> I;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    long long num = exp(8.0 * I * log(2) / n)-1;
    if (8.0 * I * log(2) / n > 22)
        printf("0\n");
    else
    {
        sort(a + 1, a + 1 + n);
        int cur = 1;
        int MAX = 0;
        for (int i = 1; i <= n; i++)
        {
            while (cur + 1 <= n && a[cur + 1] - a[i] <= num)
            {
                cur++;
            }
            MAX = max(cur - i + 1, MAX);
        }
        printf("%d\n", n - MAX);
    }
}


#include <bits/stdc++.h>
using namespace std;
int a[400005];
int mp[400005];
int MAX=0;
int sum[400005];
int num;
int main()
{
    freopen("in.txt","r",stdin);
    int n, I;
    cin >> n >> I;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    int cnt=0;
    sort(a + 1, a + 1 + n);
    a[0]=-1;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==a[i-1])
        {
            mp[cnt]++;
        }
        else
        {
            mp[++cnt]++;
        }
    }
    for(int i=1;i<=cnt;i++)
    {
        sum[i]=sum[i-1]+mp[i];
    }
    int num=8*I/n;
    if(num>=19) printf("%d",0);
    else
    {
        num=1<<num;
        int cur;
        for(int i=1;i<=cnt;i++)
        {
            cur=min(cnt,i+num);
            MAX=max(MAX,sum[cur]-sum[i-1]);
        }
    }
    printf("%d\n",n-MAX);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[400005];
int num;
int main()
{
    int n,I;
    cin>>n>>I;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    long long num=exp(8.0*I*log(2)/n)-1.0;
   // cout<<num<<endl;
    sort(a+1,a+1+n);
    int cur=1;
    int MAX=0;
    for(int i=1;i<=n;i++)
    {
        while(cur+1<=n&&a[cur+1]-a[i]<=num)
        {cur++;}
        MAX=max(cur-i+1,MAX);
    }
    printf("%d\n",n-MAX);
}


#include <bits/stdc++.h>
using namespace std;
int a[400005];
int mp[400005];
int MAX=0;
int sum[400005];
int num;
int main()
{
    //freopen("in.txt","r",stdin);
    int n, I;
    cin >> n >> I;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    int cnt=0;
    sort(a + 1, a + 1 + n);
    a[0]=-1;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==a[i-1])
        {
            mp[cnt]++;
        }
        else
        {
            mp[++cnt]++;
        }
    }
    for(int i=1;i<=cnt;i++)
    {
        sum[i]=sum[i-1]+mp[i];
    }
    int num=8*I/n;
    if(num>=19) printf("%d",0);
    else
    {
        num=1<<num;
        int cur;
        for(int i=1;i<=cnt;i++)
        {
            cur=min(cnt,i+num);
            MAX=max(MAX,sum[cur]-sum[i-1]);
        }
    }
    printf("%d\n",n-MAX);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[400005];
int num;
int main()
{
    int n,I;
    cin>>n>>I;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    long long num=exp(8.0*I*log(2)/n)-0.9998;
   // cout<<num<<endl;
    sort(a+1,a+1+n);
    int cur=1;
    int MAX=0;
    for(int i=1;i<=n;i++)
    {
        while(cur+1<=n&&a[cur+1]-a[i]<=num)
        {cur++;}
        MAX=max(cur-i+1,MAX);
    }
    printf("%d\n",n-MAX);
}


#include<bits/stdc++.h>
using namespace std;
int a[400005];
int num;
int main()
{
    int n,I;
    cin>>n>>I;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    long long num=exp(8.0*I*log(2)/n)-0.999999;
   // cout<<num<<endl;
    sort(a+1,a+1+n);
    int cur=1;
    int MAX=0;
    for(int i=1;i<=n;i++)
    {
        while(cur+1<=n&&a[cur+1]-a[i]<=num)
        {cur++;}
        MAX=max(cur-i+1,MAX);
    }
    printf("%d\n",n-MAX);
}


#include <bits/stdc++.h>
using namespace std;
int a[400005];
int mp[400005];
int MAX=0;
int sum[400005];
int num;
int main()
{
    //freopen("in.txt","r",stdin);
    int n, I;
    cin >> n >> I;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    int cnt=0;
    sort(a + 1, a + 1 + n);
    a[0]=-1;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==a[i-1])
        {
            mp[cnt]++;
        }
        else
        {
            mp[++cnt]++;
        }
    }
    for(int i=1;i<=cnt;i++)
    {
        sum[i]=sum[i-1]+mp[i];
    }
    int num=8*I/n;
    if(num>=19) printf("%d",0);
    else
    {
        num=1<<num;
        int cur;
        for(int i=1;i<=cnt;i++)
        {
            cur=min(cnt,i+num-1);
            MAX=max(MAX,sum[cur]-sum[i-1]);
        }
        printf("%d\n",n-MAX);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[400005];
int num;
int main()
{
    int n, I;
    cin >> n >> I;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    long long num = exp(8.0 * I * log(2) / n)-1;
    if (8.0 * I * log(2) / n > 21)
        printf("0\n");
    else
    {
        sort(a + 1, a + 1 + n);
        int cur = 1;
        int MAX = 0;
        for (int i = 1; i <= n; i++)
        {
            while (cur + 1 <= n && a[cur + 1] - a[i] <= num)
            {
                cur++;
            }
            MAX = max(cur - i + 1, MAX);
        }
        printf("%d\n", n - MAX);
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<int,int> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in%2)ans*=t;
        in/=2;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,K=0,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            K++,b[++tp]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(K<=need)printf("0\n");
    else{
        for(int i=1;i<=tp;i++){
            c[i]=mp[b[i]];
            //cout<<c[i]<<' ';
        }
        sort(c+1,c+1+tp);
        ll ans=0;
        for(int i=1;i<=tp&&i<=K-need;i++){
            ans+=c[i];
        }
        printf("%lld\n",ans);
    }
}
/***
k<=rg
K<=2^(rg)
***/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<int,int> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in%2)ans*=t;
        in/=2;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,K=0,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            K++,b[++tp]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(K<=need)printf("0\n");
    else{
        sort(b+1,b+1+tp);
        for(int i=1;i<=tp;i++){
            c[i]=mp[b[i]];
            //cout<<c[i]<<' ';
        }

        ll ans=0;
        for(int cnt=1,i=1,j=tp;i<=j&&cnt<=K-need;cnt++){
            if(c[i]<=c[j])
            ans+=c[i],i++;
            else{
                ans+=c[j],j--;
            }
        }
        printf("%lld\n",ans);
    }
}
/***
k<=rg
K<=2^(rg)
***/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<ll,ll> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in&1)ans*=t;
        in<<=1;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,K=0,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            K++,b[++tp]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(K==1||K<=need)printf("0\n");
    else{
        sort(b+1,b+1+tp);
        for(int i=1;i<=tp;i++){
            c[i]=mp[b[i]];
            //cout<<c[i]<<' ';
        }

        ll ans=0;
        for(int cnt=1,i=1,j=tp;i<=j&&cnt<=K-need;cnt++){
            if(c[i]<c[j])
            ans+=c[i],i++;
            else{
                ans+=c[j],j--;
            }
        }
        printf("%lld\n",ans);
    }
}
/***
k<=rg
K<=2^(rg)
***/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<ll,ll> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in&1)ans*=t;
        in=in>>1;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,K=0,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            K++,b[++tp]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(K==1||K<=need)printf("0\n");
    else{
        sort(b+1,b+1+tp);
        ll ans=0;
        for(int cnt=1,i=1,j=tp;i<=j&&cnt<=K-need;cnt++){
            if(mp[b[i]]<=mp[b[j]])
            ans+=mp[b[i]],i++;
            else{
                ans+=mp[b[j]],j--;
            }
        }
        printf("%lld\n",ans);
    }
}
/***
k<=rg
K<=2^(rg)
***/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<int,int> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in&1)ans*=t;
        in>>=1;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    if(rg>33)rg=33;/// K<=4e5 -> rg<=33,����������Ļ��������ǻᱬlong long
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            b[++tp]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(tp<=need)printf("0\n");
    else{
        sort(b+1,b+1+tp);
        c[0]=0;
        for(int i=1;i<=tp;i++){
            c[i]=c[i-1]+mp[b[i]];
        }
        ll ans=0x3f3f3f3f;
        for(int i=1;i<=tp-need;i++){
            ans=min(ans,(ll)n-(c[i+need]-c[i]));
        }
        printf("%lld\n",ans);
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<ll,ll> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in&1)ans*=t;
        in=in>>1;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,K=0,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            K++,b[++tp]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(K==1||K<=need)printf("0\n");
    else{
        sort(b+1,b+1+tp);
        ll ans=0;
        for(int cnt=1,i=1,j=tp;i<=j&&cnt<=K-need;cnt++){
            if(mp[b[i]]<mp[b[j]])
            ans+=mp[b[i]],i++;
            else{
                ans+=mp[b[j]],j--;
            }
        }
        printf("%lld\n",ans);
    }
}
/***
k<=rg
K<=2^(rg)
***/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<int,int> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in&1)ans*=t;
        in<<=1;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    if(rg>33)rg=33;/// K<=4e5 -> rg<=33,����������Ļ��������ǻᱬlong long
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            b[++tp]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(tp<=need)printf("0\n");
    else{
        sort(b+1,b+1+tp);
        c[0]=0;
        for(int i=1;i<=tp;i++){
            c[i]=c[i-1]+mp[b[i]];
        }
        ll ans=0x3f3f3f3f;
        for(int i=1;i<=tp-need;i++){
            ans=min(ans,(ll)n-(c[i+need]-c[i]));
        }
        printf("%lld\n",ans);
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<int,int> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in%2)ans*=t;
        in/=2;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,K=0,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    if(rg>33)rg=33;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            K++,b[tp++]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(K<=need)printf("0\n");
    else{
        c[0]=0;
        sort(b,b+tp);
        for(int i=0;i<tp;i++){
            c[i+1]=c[i]+mp[b[i]];
//            cout<<c[i]<<' ';
        }

        ll ans=0x3f3f3f3f;
        for(int i=1;i<=n-need+1;i++){
            ans=min(ans,(ll)n-(c[i+need-1]-c[i-1]));
        }
        printf("%lld\n",ans);
    }
}
/***
1 2 2 3 4 4 4 5 5
122344455
222344455
222344444
333344444
444444444

15
24
3

***/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<int,int> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in%2)ans*=t;
        in/=2;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,K=0,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    if(rg>33)rg=33;/// K<=4e5 -> rg<=33
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            K++,b[++tp]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(K<=need)printf("0\n");
    else{
        sort(b,b+tp);
        c[0]=0;
        for(int i=1;i<=tp;i++){
            c[i]=c[i-1]+mp[b[i]];
        }
        ll ans=0x3f3f3f3f;
        for(int i=1;i<=tp-need;i++){
            ans=min(ans,(ll)n-(c[i+need]-c[i]));
        }
        printf("%lld\n",ans);
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5,inf=0x3f3f3f3f;
int a[amn],b[amn],c[amn];
map<int,int> mp;
ll qp(ll in){   ///������
    ll ans=1,t=2;
    while(in){
        if(in&1)ans*=t;
        in>>=1;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;    ///k=log2(K),n*k<=8*I,k<=8*I/n
    if(rg>32)rg=32;/// K<=4e5 -> rg<=33,����������Ļ��������ǻᱬlong long
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(!mp[a[i]])       ///���a[i]û��ͳ�ƹ�
            b[++tp]=a[i];   ///ͳ�����ж�����
        mp[a[i]]++;         ///ͳ�����ĸ���
    }
    ll need=qp(rg);         ///�����ݼ������Ҫʣ���ٸ�,K<=2^(k)<=2^(8*I/n)
    if(tp<=need)printf("0\n");
    else{
        sort(b+1,b+1+tp);   ///�����д�С����
        c[0]=0;
        for(int i=1;i<=tp;i++){
            c[i]=c[i-1]+mp[b[i]];   ///���ĸ�����ǰ׺��
        }
        ll ans=inf;
        for(int i=1;i<=tp-need;i++){
            ans=min(ans,(ll)n-(c[i+need]-c[i]));    ///Ҫɾȥ���ٵ���Ŀ������������ȥʣ�µľ���Ҫɾ���ģ�ʣ�µĸ�����need
        }
        printf("%lld\n",ans);
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<ll,ll> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in&1)ans*=t;
        in=in>>1;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,K=0,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            K++,b[++tp]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(K==1||K<=need)printf("0\n");
    else{
        sort(b+1,b+1+tp);
        for(int i=1;i<=tp;i++){
            c[i]=mp[b[i]];
            //cout<<c[i]<<' ';
        }

        ll ans=0;
        for(int cnt=1,i=1,j=tp;i<=j&&cnt<=K-need;cnt++){
            if(c[i]<=c[j])
            ans+=c[i],i++;
            else{
                ans+=c[j],j--;
            }
        }
        printf("%lld\n",ans);
    }
}
/***
k<=rg
K<=2^(rg)
***/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<int,int> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in%2)ans*=t;
        in/=2;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,K=0,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    if(rg>33)rg=33;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            K++,b[tp++]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(K<=need)printf("0\n");
    else{
        c[0]=0;
        sort(b,b+tp);
        for(int i=0;i<tp;i++){
            c[i+1]=c[i]+mp[b[i]];
        }

        ll ans=0x3f3f3f3f;
        for(int i=1;i<=tp-need+1;i++){
            ans=min(ans,(ll)n-(c[i+need-1]-c[i-1]));
        }
        printf("%lld\n",ans);
    }
}
/***
1 2 2 3 4 4 4 5 5
122344455
222344455
222344444
333344444
444444444

15
24
3

***/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int amn=4e5+5;
int a[amn],b[amn],c[amn];
map<int,int> mp;
ll qp(ll in){
    ll ans=1,t=2;
    while(in){
        if(in%2)ans*=t;
        in/=2;
        t*=t;
    }
    return ans;
}
int main(){
    int n,I,K=0,tp=0;
    cin>>n>>I;
    ll rg=8*I/n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(!mp[a[i]])
            K++,b[tp++]=a[i];
        mp[a[i]]++;
    }
    ll need=qp(rg);
    if(K<=need)printf("0\n");
    else{
        c[0]=0;
        sort(b,b+tp);
        for(int i=0;i<tp;i++){
            c[i+1]=c[i]+mp[b[i]];
//            cout<<c[i]<<' ';
        }

        ll ans=0x3f3f3f3f;
        for(int i=1;i<=n-need+1;i++){
            ans=min(ans,(ll)n-(c[i+need-1]-c[i-1]));
        }
        printf("%lld\n",ans);
    }
}
/***
1 2 2 3 4 4 4 5 5
122344455
222344455
222344444
333344444
444444444

15
24
3

***/


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	while(j<=z && n*((long long)ceil((long double)log2(dis)))>i*8) {
	    if(mmap[arr[j]]<mmap[arr[z]]){
	    	dis--;
	    	numchanges+=mmap[arr[j]];
	    	j++;
	    }else{
	    	dis--;
	    	numchanges+=mmap[arr[z]];
	    	z--;
	    }
	}
//	cout << n*(ceil(log2(dis))) << "\n";
	cout << numchanges << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	while(j<z && n*((long long)ceil((long double)log2(dis)))>i*8) {
	    if(mmap[arr[j]]<mmap[arr[z]]){
	    	dis--;
	    	numchanges+=mmap[arr[j]];
	    	j++;
	    }else{
	    	dis--;
	    	numchanges+=mmap[arr[z]];
	    	z--;
	    }
	}
	long long mine=numchanges;
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+mmap[arr[i-1]];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,presum[i+dis]-presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	long long l=1,r=dis;
	while(l<r) {
		long long mid=(l+r)/2;
		//cout << "mid " << mid << "\n";
		if(r==l+1){
			if(n*((long long)ceil((long double)log2(r)))<=i*8){
				l=r;
			}
			break;
		}
	    if(n*((long long)ceil((long double)log2(mid)))<=i*8){
	    	l=mid;
	    }else
	    	r=mid-1;

	}
	dis=l;
	long long mine=n+1;
	//cout << "numch : " << numchanges << "\n";
//	cout << "dis : " << dis << "\n";
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+mmap[arr[i-1]];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,n-presum[i+dis]+presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	long long l=1,r=dis;
	while(l<r) {
		long long mid=(l+r)/2;
		cout << "mid " << mid << "\n";
		if(r==l+1){
			if(n*((long long)ceil((long double)log2(r)))<=i*8){
				l=r;
			}
			break;
		}
	    if(n*((long long)ceil((long double)log2(mid)))<=i*8){
	    	l=mid;
	    }else
	    	r=mid-1;

	}
	dis=l;
	long long mine=n+1;
	//cout << "numch : " << numchanges << "\n";
//	cout << "dis : " << dis << "\n";
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+mmap[arr[i-1]];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,n-presum[i+dis]+presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	while(j<z && n*((long long)ceil((long double)log2(dis)))>i*8) {
	    if(mmap[arr[j]]<mmap[arr[z]]){
	    	dis--;
	    	numchanges+=mmap[arr[j]];
	    	j++;
	    }else{
	    	dis--;
	    	numchanges+=mmap[arr[z]];
	    	z--;
	    }
	}
	long long mine=numchanges;;
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+arr[i-1];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,presum[i+dis]-presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	long long l=1,r=dis;
	while(l<r) {
		long long mid=(l+r)/2;
		//cout << "mid " << mid << "\n";
	    if(n*((long long)ceil((long double)log2(mid)))<=i*8){
	    	l=mid;
	    }else
	    	r=mid-1;

	}
	dis=l;
	long long mine=n+1;
	//cout << "numch : " << numchanges << "\n";
//	cout << "dis : " << dis << "\n";
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+mmap[arr[i-1]];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,n-presum[i+dis]+presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	//long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	long long l=1,r=n;
	while(l<r) {
		long long mid=(l+r)/2;
	//	cout << "mid " << mid << "\n";
	    if(n*((long long)ceil((long double)log2(mid)))>i*8){
	    	r=mid-1;
	    }else{
	    	l=mid;
	    }
	}
	dis=l;
	long long mine=n;
	//cout << "numch : " << numchanges << "\n";
//	cout << "dis : " << dis << "\n";
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+mmap[arr[i-1]];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,n-presum[i+dis]+presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	while(j<z && n*((long long)ceil((long double)log2(dis)))>i*8) {
	    if(mmap[arr[j]]<mmap[arr[z]]){
	    	dis--;
	    	numchanges+=mmap[arr[j]];
	    	j++;
	    }else{
	    	dis--;
	    	numchanges+=mmap[arr[z]];
	    	z--;
	    }
	}
	long long maxe=0;
		for(auto&& i : mmap) {
			maxe=max(maxe,i.second);
	}
	cout << min(numchanges,n-maxe) << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	while(j<z && n*((long long)ceil((long double)log2(dis)))>i*8) {
	    if(mmap[arr[j]]<mmap[arr[z]]){
	    	dis--;
	    	numchanges+=mmap[arr[j]];
	    	j++;
	    }else{
	    	dis--;
	    	numchanges+=mmap[arr[z]];
	    	z--;
	    }
	}
//	cout << n*(ceil(log2(dis))) << "\n";
	cout << numchanges << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	while(j<z && n*((long long)ceil((long double)log2(dis)))>i*8) {
	    if(mmap[arr[j]]<mmap[arr[z]]){
	    	dis--;
	    	numchanges+=mmap[arr[j]];
	    	j++;
	    }else{
	    	dis--;
	    	numchanges+=mmap[arr[z]];
	    	z--;
	    }
	}
	long long maxe=0;
		for(auto&& i : mmap) {
			maxe=max(maxe,i.second);
	}
	cout << min(numchanges,maxe) << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	long long l=1,r=n;
	while(l<r) {
		long long mid=(l+r)/2;
		//cout << "mid " << mid << "\n";
	    if(n*((long long)ceil((long double)log2(mid)))>i*8){
	    	r=mid-1;
	    }else if(n*((long long)ceil((long double)log2(mid)))==i*8){
	    	l=mid;
	    }else
	    	l=mid+1;
	}
	dis=l;
	long long mine=n;
	//cout << "numch : " << numchanges << "\n";
//	cout << "dis : " << dis << "\n";
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+mmap[arr[i-1]];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,n-presum[i+dis]+presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	while(j<z && n*((long long)ceil((long double)log2(dis)))>i*8) {
	    if(mmap[arr[j]]<mmap[arr[z]]){
	    	dis--;
	    	numchanges+=mmap[arr[j]];
	    	j++;
	    }else{
	    	dis--;
	    	numchanges+=mmap[arr[z]];
	    	z--;
	    }
	}
	long long mine=numchanges;
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+arr[i-1];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,presum[i+dis]-presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	long long l=1,r=n;
	while(l<r) {
		long long mid=(l+r)/2;
		//cout << "mid " << mid << "\n";
	    if(n*((long long)ceil((long double)log2(mid)))>i*8){
	    	r=mid-1;
	    }else if(n*((long long)ceil((long double)log2(mid)))==i*8){
	    	l=mid;
	    }else
	    	l=mid+1;
	}
	dis=l;
	long long mine=n+1;
	//cout << "numch : " << numchanges << "\n";
//	cout << "dis : " << dis << "\n";
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+mmap[arr[i-1]];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,n-presum[i+dis]+presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	while(j<z && n*((long long)ceil((long double)log2(dis)))>i*8) {
	    if(mmap[arr[j]]<mmap[arr[z]]){
	    	dis--;
	    	numchanges+=mmap[arr[j]];
	    	j++;
	    }else{
	    	dis--;
	    	numchanges+=mmap[arr[z]];
	    	z--;
	    }
	}
	if (j==z)
	{
		long long maxe=0;
		for(auto&& i : mmap) {
			maxe=max(maxe,i.second);
		}
		cout << n-maxe << "\n";
	}else
		cout << numchanges << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	long long l=1,r=dis;
	while(l<r) {
		long long mid=(l+r)/2;
		//cout << "mid " << mid << "\n";
		if(r==l+1){
			if(n*((long long)ceil((long double)log2(r)))<=i*8){
				l=r;
			}
			break;
		}
	    if(n*((long long)ceil((long double)log2(mid)))<=i*8){
	    	l=mid;
	    }else
	    	r=mid-1;

	}
	dis=l;
	long long mine=n+1;
	//cout << "numch : " << numchanges << "\n";
//	cout << "dis : " << dis << "\n";
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+mmap[arr[i-1]];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,n-presum[i+dis]+presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	while(j<=z && n*(ceil((long double)log2(dis)))>i*8) {
	    if(mmap[arr[j]]<mmap[arr[z]]){
	    	dis--;
	    	numchanges+=mmap[arr[j]];
	    }else{
	    	dis--;
	    	numchanges+=mmap[arr[z]];
	    }
	}
//	cout << n*(ceil(log2(dis))) << "\n";
	cout << numchanges << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	long long l=1,r=n;
	while(l<r) {
		long long mid=(l+r)/2;
		//cout << "mid " << mid << "\n";
	    if(n*((long long)ceil((long double)log2(mid)))>i*8){
	    	r=mid-1;
	    }else{
	    	l=mid+1;
	    }
	}
	dis=l;
	long long mine=n;
	//cout << "numch : " << numchanges << "\n";
//	cout << "dis : " << dis << "\n";
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+mmap[arr[i-1]];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,n-presum[i+dis]+presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,i,x;
	cin >> n >> i;
	set<long long>ss;
	vector<long long > arr;
	map<long long,long long >mmap;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ss.insert(x);
		mmap[x]++;
	}
	for(auto&& i : ss) {
		arr.push_back(i);
	//	cout << "i : " << i << "\n";
	}
	//long long k=ceil((long double)(log2(arr.size())));
	long long j=0,z=arr.size()-1;
	long long numchanges=0,dis=arr.size();
//	cout << "dis : " << dis << "\n";
	while(j<z && n*((long long)ceil((long double)log2(dis)))>i*8) {
	    if(mmap[arr[j]]<mmap[arr[z]]){
	    	dis--;
	    	numchanges+=mmap[arr[j]];
	    	j++;
	    }else{
	    	dis--;
	    	numchanges+=mmap[arr[z]];
	    	z--;
	    }
	}
	long long mine=numchanges;
	//cout << "numch : " << numchanges << "\n";
//	cout << "dis : " << dis << "\n";
	vector<long long>presum(arr.size()+1,0);
	for (int i = 1; i <=arr.size() ; ++i)
		presum[i]=presum[i-1]+mmap[arr[i-1]];

	for (int i = 0; i <=arr.size()-dis; ++i)
	{
		mine=min(mine,n-presum[i+dis]+presum[i]);
	}
	cout << mine << "\n";

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, I;
    cin>>n>>I;
    int K=0;
    int ck;

    multiset<int> freq;

    vector<long long int> soundFile(n, 0);

    for(int i=0;i< n ; i++)
    {
        cin>>soundFile[i];

        if(freq.count(soundFile[i])==0)
        {
            K++;
        }

        freq.insert(soundFile[i]);
    }

    ck=ceil(log2(K));
    int k = floor(8*((float)I/n));

    int cost=0;

    while(ck > k)
    {
        long long int max = *freq.begin();
        long long int min = *freq.rbegin();

        // cout<<"max elem = "<<max<<" min elem = "<<min<<endl;

        int l = freq.count(max);
        int r = freq.count(min);

        // cout<<"freq of max = "<<l<<" freq of min = "<<r<<endl;

        int del;

        // cout<<"l = "<<l<<" r = "<<r<<endl;

        if(l < r)
        {
            cost+=l;
            del=max;
        }
        else
        {
            cost+=r;
            del=min;
        }
        freq.erase(del);
        K--;
        ck=ceil(log2(K));
    }

    cout<<cost<<endl;

}


#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, I;
    cin>>n>>I;
    int K=0;
    int ck;

    multiset<long long int> freq;

    vector<long long int> soundFile(n, 0);

    for(int i=0;i< n ; i++)
    {
        cin>>soundFile[i];

        if(freq.count(soundFile[i])==0)
        {
            K++;
        }

        freq.insert(soundFile[i]);
    }

    ck=ceil(log2(K));

    int cost=0;

    while(n*ck > I*8)
    {
        long long int max = *freq.begin();
        long long int min = *freq.rbegin();

        // cout<<"max elem = "<<max<<" min elem = "<<min<<endl;

        int l = freq.count(max);
        int r = freq.count(min);

        // cout<<"freq of max = "<<l<<" freq of min = "<<r<<endl;

        int del;

        // cout<<"l = "<<l<<" r = "<<r<<endl;

        if(l < r)
        {
            cost+=l;
            del=max;
        }
        else
        {
            cost+=r;
            del=min;
        }
        freq.erase(del);
        K--;
        ck=ceil(log2(K));
        if(n*ck <= I*8)
        {
            break;
        }

    }

    cout<<cost<<endl;

}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

#define inf 0xf3f3f3

void bug(vector<int> a, int n)
{
    for(int i=0; i < n ; i++)
    {
        cout<<a[i]<<' ';
    }
    cout<<endl;
}

void bug(map<int, int> m)
{
    for(auto it = m.begin() ; it != m.end() ; it++)
    {
        cout<<it->first<<" => "<<it->second<<endl;
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, I;

    cin>>n>>I;

    int bits_per_instant = (I*8)/n;

    map<int, int> freq;

    vector<int> a(400005);
    vector<int> sum_by_index(400005);
    vector<int> distinct;

    for(int i = 0; i < n ; i++)
    {
        cin>>a[i];
        freq[a[i]]++;
    }

    // bug(a, n);
    // bug(freq);

    for(auto x : freq)
    {
        distinct.push_back(x.first);
    }

    sort(distinct.begin(), distinct.end());
    // bug(distinct, distinct.size());

    sum_by_index[0]=freq[distinct[0]];
    for(int i=1;i < distinct.size(); i++)
    {
        sum_by_index[i] = sum_by_index[i-1]+ freq[distinct[i]];
    }

    // bug(sum_by_index, distinct.size());

    int K = 1;
    int f=1;

    for(int i=0; i < bits_per_instant ; i++)
    {
        K *=2;
        if(K >= distinct.size())
        {
            f=0;
            break;
        }

        K = min(inf, K);

    }

    // cout<<"K = "<<K<<endl;

    int s;
    int mn = inf;
    s= min(mn,  n - sum_by_index[K-1]);

    for(int i=0; i+K - 1 < n ; i++)
    {

        if(i==0)
        {
            s = min(s , n - sum_by_index[i+K-1]);
        }
        else
        {
            s = min(s , n - (sum_by_index[i+K-1]-sum_by_index[i-1]));
        }

        // cout<<"s = "<<s<<endl;
        s = min(mn, s);
    }

    // cout<<s<<endl;

    if(f)
    {
        cout<<s;
    }
    else
    {
        cout<<0<<endl;
    }

    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, I;
    cin>>n>>I;
    int K=0;
    int ck;

    multiset<int> freq;

    vector<int> soundFile(n, 0);

    for(int i=0;i< n ; i++)
    {
        cin>>soundFile[i];

        if(freq.count(soundFile[i])==0)
        {
            K++;
        }

        freq.insert(soundFile[i]);
    }
    ck=ceil(log2(K));
    int k = floor(8*((float)I/n));

    int cost=0;

    while(ck > k)
    {
        int max = *freq.begin();
        int min = *freq.rbegin();

        int l = freq.count(max);
        int r = freq.count(min);

        int del;

        // cout<<"l = "<<l<<" r = "<<r<<endl;

        if(l < r)
        {
            cost+=freq.count(l);
            del=max;
        }
        else
        {
            cost+=freq.count(r);
            del=min;
        }
        freq.erase(del);
        K--;
        ck=ceil(log2(K));
    }

    cout<<cost<<endl;

}


#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, I;
    cin>>n>>I;
    int K=0;
    int ck;

    multiset<int> freq;

    vector<long long int> soundFile(n, 0);

    for(int i=0;i< n ; i++)
    {
        cin>>soundFile[i];

        if(freq.count(soundFile[i])==0)
        {
            K++;
        }

        freq.insert(soundFile[i]);
    }

    ck=ceil(log2(K));
    int k = floor(8*((float)I/n));

    int cost=0;

    while(ck > k)
    {
        long long int max = *freq.begin();
        long long int min = *freq.rbegin();

        int l = freq.count(max);
        int r = freq.count(min);

        int del;

        // cout<<"l = "<<l<<" r = "<<r<<endl;

        if(l < r)
        {
            cost+=freq.count(l);
            del=max;
        }
        else
        {
            cost+=freq.count(r);
            del=min;
        }
        freq.erase(del);
        K--;
        ck=ceil(log2(K));
    }

    cout<<cost<<endl;

}


#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int main()
{

    int n, I;
    cin>>n>>I;
    int K=0;
    int ck;

    multiset<int> freq;

    vector<long long int> soundFile(n, 0);

    for(int i=0;i< n ; i++)
    {
        cin>>soundFile[i];

        if(freq.count(soundFile[i])==0)
        {
            K++;
        }

        freq.insert(soundFile[i]);
    }

    ck=ceil(log2(K));
    int k = floor(8*((float)I/n));

    int cost=0;

    while(n*ck > I*8)
    {
        long long int max = *freq.begin();
        long long int min = *freq.rbegin();

        // cout<<"max elem = "<<max<<" min elem = "<<min<<endl;

        int l = freq.count(max);
        int r = freq.count(min);

        // cout<<"freq of max = "<<l<<" freq of min = "<<r<<endl;

        int del;

        // cout<<"l = "<<l<<" r = "<<r<<endl;

        if(l < r)
        {
            cost+=l;
            del=max;
        }
        else
        {
            cost+=r;
            del=min;
        }
        freq.erase(del);
        K--;
        ck=ceil(log2(K));
        if(n*ck <= I*8)
        {
            break;
        }

    }

    cout<<cost<<endl;

}


#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, I;
    cin>>n>>I;
    int K=0;
    int ck;

    multiset<int> freq;

    vector<long long int> soundFile(n, 0);

    for(int i=0;i< n ; i++)
    {
        cin>>soundFile[i];

        if(freq.count(soundFile[i])==0)
        {
            K++;
        }

        freq.insert(soundFile[i]);
    }

    ck=ceil(log2(K));
    int k = floor(8*((float)I/n));

    int cost=0;

    while(n*ck <= I*8)
    {
        long long int max = *freq.begin();
        long long int min = *freq.rbegin();

        // cout<<"max elem = "<<max<<" min elem = "<<min<<endl;

        int l = freq.count(max);
        int r = freq.count(min);

        // cout<<"freq of max = "<<l<<" freq of min = "<<r<<endl;

        int del;

        // cout<<"l = "<<l<<" r = "<<r<<endl;

        if(l < r)
        {
            cost+=l;
            del=max;
        }
        else
        {
            cost+=r;
            del=min;
        }
        freq.erase(del);
        K--;
        ck=ceil(log2(K));
        if(n*ck <= I*8)
        {
            break;
        }

    }

    cout<<cost<<endl;

}


#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, I;
    cin>>n>>I;
    int K=0;
    int ck;

    multiset<int> freq;

    vector<long long int> soundFile(n, 0);

    for(int i=0;i< n ; i++)
    {
        cin>>soundFile[i];

        if(freq.count(soundFile[i])==0)
        {
            K++;
        }

        freq.insert(soundFile[i]);
    }

    ck=ceil(log2(K));
    int k = floor(8*((float)I/n));

    int cost=0;

    while(ck > k)
    {
        long long int max = *freq.begin();
        long long int min = *freq.rbegin();

        // cout<<"max elem = "<<max<<" min elem = "<<min<<endl;

        int l = freq.count(max);
        int r = freq.count(min);

        // cout<<"freq of max = "<<l<<" freq of min = "<<r<<endl;

        int del;

        // cout<<"l = "<<l<<" r = "<<r<<endl;

        if(l < r)
        {
            cost+=l;
            del=max;
        }
        else
        {
            cost+=r;
            del=min;
        }
        freq.erase(del);
        K--;
        ck=ceil(log2(K));
        if(n*ck <= I*8)
        {
            break;
        }

    }

    cout<<cost<<endl;

}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

#define inf 0xf3f3f3

void bug(vector<int> a, int n)
{
    for(int i=0; i < n ; i++)
    {
        cout<<a[i]<<' ';
    }
    cout<<endl;
}

void bug(map<int, int> m)
{
    for(auto it = m.begin() ; it != m.end() ; it++)
    {
        cout<<it->first<<" => "<<it->second<<endl;
    }

}

int main()
{
    int n, I;

    cin>>n>>I;

    int bits_per_instant = (I*8)/n;

    map<int, int> freq;

    vector<int> a(400005);
    vector<int> sum_by_index(400005);
    vector<int> distinct;

    for(int i = 0; i < n ; i++)
    {
        cin>>a[i];
        freq[a[i]]++;
    }

    // bug(a, n);
    // bug(freq);

    for(auto x : freq)
    {
        distinct.push_back(x.first);
    }

    sort(distinct.begin(), distinct.end());
    // bug(distinct, distinct.size());

    sum_by_index[0]=freq[distinct[0]];
    for(int i=1;i < distinct.size(); i++)
    {
        sum_by_index[i] = sum_by_index[i-1]+ freq[distinct[i]];
    }

    // bug(sum_by_index, distinct.size());

    int K = 1;
    int f=1;

    for(int i=0; i < bits_per_instant ; i++)
    {
        K *=2;
        if(K >= distinct.size())
        {
            f=0;
            break;
        }

        K = min(inf, K);

    }

    // cout<<"K = "<<K<<endl;

    int s;
    int mn = inf;
    s= min(mn,  n - sum_by_index[K-1]);

    for(int i=0; i+K - 1 < n ; i++)
    {

        if(i==0)
        {
            s = min(s , n - sum_by_index[i+K-1]);
        }
        else
        {
            s = min(s , n - (sum_by_index[i+K-1]-sum_by_index[i-1]));
        }

        // cout<<"s = "<<s<<endl;
        s = min(mn, s);
    }

    // cout<<s<<endl;

    if(f)
    {
        cout<<s;
    }
    else
    {
        cout<<0<<endl;
    }

    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, I;
    cin>>n>>I;
    int K=0;
    int ck;

    multiset<int> freq;

    vector<long long int> soundFile(n, 0);

    for(int i=0;i< n ; i++)
    {
        cin>>soundFile[i];

        if(freq.count(soundFile[i])==0)
        {
            K++;
        }

        freq.insert(soundFile[i]);
    }

    ck=ceil(log2(K));
    int k = floor(8*((float)I/n));

    int cost=0;

    while(1)
    {
        long long int max = *freq.begin();
        long long int min = *freq.rbegin();

        // cout<<"max elem = "<<max<<" min elem = "<<min<<endl;

        int l = freq.count(max);
        int r = freq.count(min);

        // cout<<"freq of max = "<<l<<" freq of min = "<<r<<endl;

        int del;

        // cout<<"l = "<<l<<" r = "<<r<<endl;

        if(l < r)
        {
            cost+=l;
            del=max;
        }
        else
        {
            cost+=r;
            del=min;
        }
        freq.erase(del);
        K--;
        ck=ceil(log2(K));
        if(n*ck <= I*8)
        {
            break;
        }

    }

    cout<<cost<<endl;

}


#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, I;
    cin>>n>>I;
    int K=0;
    int ck;

    multiset<int> freq;

    vector<int> soundFile(n, 0);

    for(int i=0;i< n ; i++)
    {
        cin>>soundFile[i];

        if(freq.count(soundFile[i])==0)
        {
            K++;
        }

        freq.insert(soundFile[i]);
    }
    ck=ceil(log2(K));
    int k = floor(8*((float)I/n));

    int cost=0;

    while(ck > k)
    {
        int l= *freq.begin();
        int r = *freq.rbegin();

        int del;

        if(l < r)
        {
            cost+=freq.count(l);
            del=l;
        }
        else
        {
            cost+=freq.count(r);
            del=r;
        }
        freq.erase(del);
        K--;
        ck=ceil(log2(K));
    }

    cout<<cost<<endl;

}


#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, I;
    cin>>n>>I;
    int K=0;
    int ck;

    multiset<int> freq;

    vector<long long int> soundFile(n, 0);

    for(int i=0;i< n ; i++)
    {
        cin>>soundFile[i];

        if(freq.count(soundFile[i])==0)
        {
            K++;
        }

        freq.insert(soundFile[i]);
    }

    ck=ceil(log2(K));
    int k = floor(8*((float)I/n));

    int cost=0;

    while(n*ck > I*8)
    {
        long long int max = *freq.begin();
        long long int min = *freq.rbegin();

        // cout<<"max elem = "<<max<<" min elem = "<<min<<endl;

        int l = freq.count(max);
        int r = freq.count(min);

        // cout<<"freq of max = "<<l<<" freq of min = "<<r<<endl;

        int del;

        // cout<<"l = "<<l<<" r = "<<r<<endl;

        if(l < r)
        {
            cost+=l;
            del=max;
        }
        else
        {
            cost+=r;
            del=min;
        }
        freq.erase(del);
        K--;
        ck=ceil(log2(K));
        if(n*ck <= I*8)
        {
            break;
        }

    }

    cout<<cost<<endl;

}


#include <iostream>
#include<bits/stdc++.h>
#include<algorithm>

using namespace std;

typedef long long ll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, I;
    cin>>n>>I;
    int K=0;
    int ck;

    vector<int> soundFile(n, 0);
    vector<int> freq(n+1, 0);

    for(int i=0;i< n ; i++)
    {
        cin>>soundFile[i];

        if(freq[soundFile[i]]==0)
        {
            K++;
        }

        freq[soundFile[i]]++;
    }
    ck=ceil(log2(K));
    int k = floor(8*((float)I/n));

    // cout<<"ck = "<<ck<<" k = "<<k<<endl;

    int l=0;
    int r=0;

    for(int i=0; i < n ; i++)
    {
        if(soundFile[i]==-1) continue;

        if(soundFile[i] < soundFile[l])
        {
            l=i;
        }

        if(soundFile[i] > soundFile[r])
        {
            r=i;
        }
    }

    int cost=0;
    while(ck > k)
    {
        int del;

        // cout<<"leftmost element is = "<<soundFile[l] << " rightmost element is = "<<soundFile[r]<<endl;

        // cout<<"l = "<<l<<" r = "<<r<<endl;

        // cout<<"freq of le = "<<freq[soundFile[l]]<<" freq of re = "<<freq[soundFile[r]]<<endl;

        if(freq[soundFile[l]] < freq[soundFile[r]])
        {
            cost+=freq[soundFile[l]];
            freq[soundFile[l]]=0;
            del=soundFile[l];
        }
        else
        {
            cost+=freq[soundFile[r]];
            freq[soundFile[r]]=0;
            del=soundFile[r];
        }

        l=0;
        r=0;

        for(int i=0; i < n ; i++)
        {
            if(soundFile[i]==-1) continue;
            if(soundFile[i]==del){
                soundFile[i]=-1;
                continue;
            }
            if(soundFile[i] < soundFile[l])
            {
                l=i;
            }

            if(soundFile[i] > soundFile[r])
            {
                r=i;
            }
        }

        K--;
        ck=ceil(log2(K));
    }

    // cout<<"l = "<<soundFile[l]<<" r = "<<soundFile[r]<<endl;
    cout<<cost<<endl;

}


#include <bits/stdc++.h>
using namespace std;

#define eb emplace_back
#define pb push_back
#define INF 1LL<<62
#define FLT_INF pow(10.0, 16)

using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<ll, ll>;
using int3 = tuple<ll, ll, ll>;

template <typename A> string to_string(const A& v);
string to_string(const string& s) { return '"'+ s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(const pair<A, B>& p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C> string to_string(const tuple<A, B, C>& p) {
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) +  ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A> string to_string(const A& v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T>& val) {
  sort(val.begin(), val.end());
}

template <typename T>
void reverse(vector<T>& val) {
  reverse(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T>& val) {
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T pair_sum(pair<T, T>& val) {
  return val.first + val.second;
}

template <typename T>
T mul_mod(T a, T b, T mod) {
  T res = 0;
  a %= mod;
  while (b) {
    if (b & 1) {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...);
#endif

#define COMMON_MOD pow(10, 9) + 7
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
*/

class mytask {
public:
  mytask() { }

  int solve() {

    ll n, disk_space;
    cin >> n >> disk_space;

    vll a(n);
    //vll vals(400400, 0);

    map<ll, ll> vals_with_count;
    vll vals;

    for (int i = 0; i < n; i++) {
      cin >> a[i];
      vals_with_count[a[i]]++;
    }

    for (auto& el: vals_with_count) {
      vals.pb(el.first);
    }
    sort(vals);
    vll vals_sum(vals.size()+1);

    ll current_sum = 0;
    for (int i = 0; i < vals.size(); i++) {
      current_sum += vals_with_count[vals[i]];
      vals_sum[i+1] = current_sum;
    }
    //check for overflow
    if (((disk_space * 8) / n) > 15) {
      cout << 0;
      return 0;
    }
    debug(vals, vals_sum);

    ll vals_count = pow(2, (disk_space * 8) / n);
    ll min_broke_val = 400400;
    ll last_j = 1;
    for (int i = 0;  i < vals.size(); i++) {
      bool is_end = true;
      for (int j = last_j;  j <= vals.size(); j++) {

        if ((j - i) >= vals_count) {
          debug(i, j, vals_count);
          min_broke_val = min(min_broke_val, n - (vals_sum[j] - vals_sum[i]));
          last_j = j;
          is_end = false;
          break;
        }
      }
      if (is_end) {
        debug(i, vals.size(), is_end);
        min_broke_val = min(min_broke_val, n - (vals_sum[vals.size()] - vals_sum[i]));
        break;
      }
    }

    cout << min_broke_val;

    return 0;
  }
};

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  auto task = mytask();
  task.solve();

  cout << endl;

  return 0;
}