import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    int N = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(int i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    int numChanged = 0;
	    int size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2)-0.00005);
	    while(size > I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2)-0.00005);
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();

	}

}


import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    long N = Integer.parseInt(st.nextToken());
	    long I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(long i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    long numChanged = 0;
	    long size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    while(size >= I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();

	}

}


import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    int N = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;
	    int necessary = (int)Math.floor(Math.pow(2, I / N));
	    //System.out.println(necessary);

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(long i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    Iterator<Integer> it = map.descendingKeySet().iterator();

	    int[] sums = new int[map.size()];
	    sums[0] = map.get(it.next());
	    for(int i = 1; i < sums.length; i++) {
	    	sums[i] = sums[i-1] + map.get(it.next());
	    }

	    //System.out.println(Arrays.toString(sums));

	    int min = Integer.MAX_VALUE;
	    for(int i = necessary; i < sums.length; i++) {
	    	min = Math.min(min, N - (sums[i] - sums[i-necessary]));
	    }
	    if(min == Integer.MAX_VALUE)
	    	min = 0;
	    out.println(min);

	    out.close();
	    f.close();

	}

}
/*
import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    long N = Integer.parseInt(st.nextToken());
	    long I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(long i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    long numChanged = 0;
	    long size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    while(size > I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();

	}

}
*/


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class E {
	static FastReader scan;
	static PrintWriter out;

	public static void main(String[] args) throws FileNotFoundException {
		Solver solver = new Solver();
		scan = new FastReader();
		out = new PrintWriter(System.out);
		int testCases = 1;
		for (int i = 1; i <= testCases; i++) {
			// out.print("Case #" + i + ": ");
			solver.solve();
		}
		out.close();
	}

	static class Solver {

		void solve() {
			int n = scan.nextInt(), b = scan.nextInt(), max = b*8/n, ans = 0;
			int d = max >= 31 ? (1 << 30) : (1 << max);
			TreeMap<Integer, Integer> t = new TreeMap<>();
			ArrayList<Integer> a = new ArrayList<>();
			for(int i = 0; i < n; i++) {
				int x = scan.nextInt();
				t.put(x, t.getOrDefault(x, 0) + 1);
			}
			int curr = 0;
			for(int i : t.keySet()) a.add(curr += t.get(i));
			for(int i = 0; i < a.size(); i++) {
				int end = i+d-1 >= a.size() ? n : a.get(i+d-1);
				int start = i == 0 ? 0 : a.get(i-1);
				ans = Math.max(ans, end-start);
			}
			out.println(n-ans);
		}

	}

	// Sathvik's Template Stuff BELOW!!!!!!!!!!!!!!!!!!!!!!

	static class DSU {
		int[] root, size;
		int n;

		DSU(int n) {
			this.n = n;
			root = new int[n];
			size = new int[n];
			for (int i = 0; i < n; i++) {
				root[i] = i;
				size[i] = 1;
			}
		}

		int findParent(int idx) {
			while (root[idx] != idx) {
				root[idx] = root[root[idx]];
				idx = root[idx];
			}
			return idx;
		}

		boolean union(int x, int y) {
			int parX = findParent(x);
			int parY = findParent(y);
			if (parX == parY)
				return false;
			if (size[parX] < size[parY]) {
				root[parY] = parX;
				size[parX] += size[parY];
			} else {
				root[parX] = parY;
				size[parY] += size[parX];
			}
			return true;
		}
	}

	static class Extra {
		static void sort(int[] a) {
			Integer[] aa = new Integer[a.length];
			for (int i = 0; i < aa.length; i++)
				aa[i] = a[i];
			Arrays.sort(aa);
			for (int i = 0; i < aa.length; i++)
				a[i] = aa[i];
		}

		static void sort(long[] a) {
			Long[] aa = new Long[a.length];
			for (int i = 0; i < aa.length; i++)
				aa[i] = a[i];
			Arrays.sort(aa);
			for (int i = 0; i < aa.length; i++)
				a[i] = aa[i];
		}

		static void sort(double[] a) {
			Double[] aa = new Double[a.length];
			for (int i = 0; i < aa.length; i++)
				aa[i] = a[i];
			Arrays.sort(aa);
			for (int i = 0; i < aa.length; i++)
				a[i] = aa[i];
		}

		static void sort(char[] a) {
			Character[] aa = new Character[a.length];
			for (int i = 0; i < aa.length; i++)
				aa[i] = a[i];
			Arrays.sort(aa);
			for (int i = 0; i < aa.length; i++)
				a[i] = aa[i];
		}

		static long gcd(long a, long b) {
			while (b > 0) {
				long temp = b;
				b = a % b;
				a = temp;
			}
			return a;
		}

		static long lcm(long a, long b) {
			return a * (b / gcd(a, b));
		}

		static boolean isPrime(long n) {
			if (n <= 1)
				return false;
			if (n <= 3)
				return true;
			if (n % 2 == 0 || n % 3 == 0)
				return false;
			for (long i = 5; i * i <= n; i = i + 6) {
				if (n % i == 0 || n % (i + 2) == 0)
					return false;
			}
			return true;
		}
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] a = new double[n];
			for (int i = 0; i < n; i++)
				a[i] = nextDouble();
			return a;
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


import java.io.*;
import java.util.*;

@SuppressWarnings("Duplicates")

public class test {
    FastScanner in;
    PrintWriter out;
    boolean systemIO = true;
    int INF = Integer.MAX_VALUE / 2;
    double H, L;

    void solve2() {
        H = in.nextInt();
        L = in.nextInt();
        L = L * L;
        double l = -1, r = INF;
        while (r - l > 1e-7) {
            double x = (r + l) / 2.0;
            double xh = Math.sqrt(x * x + L);
            if (x + H > xh) {
                r = x;
            } else {
                l = x;
            }
        }
        System.out.println(r);
    }

    void solve() {
        int n = in.nextInt(), I = in.nextInt() * 8;
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            set.add(in.nextInt());
        }
        int k = I / n;
        int K = 2 << k;
        if (k == 0) {
            K = 1;
        }
        System.out.println(Math.max(n - K, 0));

    }

    private void run() throws IOException {
        if (systemIO) {
            in = new test.FastScanner(System.in);
            out = new PrintWriter(System.out);
        } else {
            in = new test.FastScanner(new File("firesafe.in"));
            out = new PrintWriter(new File("firesafe.out"));
        }
        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

    }

    public static void main(String[] arg) throws IOException {
        new test().run();
    }

}


import java.io.*;
import java.util.*;

@SuppressWarnings("Duplicates")

public class test {
    FastScanner in;
    PrintWriter out;
    boolean systemIO = true;
    int INF = Integer.MAX_VALUE / 2;
    long H, L;

    void solve() {
        int n = in.nextInt(), I = in.nextInt() * 8;
        int k = I / n;
        long K = 1 << k;
        if (K < 0) {
            System.out.println(0);
            System.exit(0);
        }
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        int[][] arr = new int[n][3];
        int id = -1;
        for (int i = 0; i < n; i++) {
            if (i != 0 && a[i] == a[i - 1]) {
                arr[id][1]++;
            } else {
                id++;
                arr[id][0] = a[i];
                arr[id][1] = 1;
            }
        }

        if (k > 19 || (1 << k) > id) {
            System.out.println(0);
            System.exit(0);
        }
        int ans = 0, kk = 0;
        int uk1 = 0, uk2 = 0;
        for (long i = K; i <= id; i++) {
            while (uk2 < i) {
                kk += arr[uk2++][1];
            }
            while (uk1 < i - K) {
                kk -= arr[uk1++][1];
            }
            ans = Math.max(ans, kk);
        }
        //System.out.println(K + " " + id);
        System.out.println(n - (K > id ? n : ans));

    }

    class pair {
        int a, b;

        pair(int A, int B) {
            this.a = A;
            this.b = B;
        }
    }

    private void run() throws IOException {
        if (systemIO) {
            in = new test.FastScanner(System.in);
            out = new PrintWriter(System.out);
        } else {
            in = new test.FastScanner(new File("firesafe.in"));
            out = new PrintWriter(new File("firesafe.out"));
        }
        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

    }

    public static void main(String[] arg) throws IOException {
        new test().run();
    }

}


import java.io.*;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;

@SuppressWarnings("Duplicates")

public class test {
    FastScanner in;
    PrintWriter out;
    boolean systemIO = true;
    int INF = Integer.MAX_VALUE / 2;
    long H, L;

    void solve() {
        int n = in.nextInt(), I = in.nextInt() * 8;
        int k = I / n;
        long K = 1 << k;
        if (K < 0) {
            System.out.println(0);
            System.exit(0);
        }
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        shuffleArray(a);
        Arrays.sort(a);
        int[][] arr = new int[n][3];
        int id = -1;
        for (int i = 0; i < n; i++) {
            if (i != 0 && a[i] == a[i - 1]) {
                arr[id][1]++;
            } else {
                id++;
                arr[id][0] = a[i];
                arr[id][1] = 1;
            }
        }

        if (k > 19 || (1 << k) > id) {
            System.out.println(0);
            System.exit(0);
        }
        int ans = 0, kk = 0;
        int uk1 = 0, uk2 = 0;
        for (long i = K; i <= id; i++) {
            while (uk2 < i) {
                kk += arr[uk2++][1];
            }
            while (uk1 < i - K) {
                kk -= arr[uk1++][1];
            }
            ans = Math.max(ans, kk);
        }
        //System.out.println(K + " " + id);
        System.out.println(n - (K > id ? n : ans));

    }

    void shuffleArray(int[] ar) {
        Random rnd = ThreadLocalRandom.current();
        for (int i = ar.length - 1; i > 0; i--) {
            int index = rnd.nextInt(i + 1);
            int a = ar[index];
            ar[index] = ar[i];
            ar[i] = a;
        }
    }

    class pair {
        int a, b;

        pair(int A, int B) {
            this.a = A;
            this.b = B;
        }
    }

    private void run() throws IOException {
        if (systemIO) {
            in = new test.FastScanner(System.in);
            out = new PrintWriter(System.out);
        } else {
            in = new test.FastScanner(new File("firesafe.in"));
            out = new PrintWriter(new File("firesafe.out"));
        }
        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

    }

    public static void main(String[] arg) throws IOException {
        new test().run();
    }

}


import java.io.*;
import java.util.*;

@SuppressWarnings("Duplicates")

public class test {
    FastScanner in;
    PrintWriter out;
    boolean systemIO = true;
    int INF = Integer.MAX_VALUE / 2;
    double H, L;

    void solve2() {
        H = in.nextInt();
        L = in.nextInt();
        L = L * L;
        double l = -1, r = INF;
        while (r - l > 1e-7) {
            double x = (r + l) / 2.0;
            double xh = Math.sqrt(x * x + L);
            if (x + H > xh) {
                r = x;
            } else {
                l = x;
            }
        }
        System.out.println(l);
    }

    void solve() {
        int n = in.nextInt(), I = in.nextInt() * 8;
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            set.add(in.nextInt());
        }
        int k = I / n;
        int K = 2 << k;
        System.out.println(Math.max(n - K, 0));

    }

    private void run() throws IOException {
        if (systemIO) {
            in = new test.FastScanner(System.in);
            out = new PrintWriter(System.out);
        } else {
            in = new test.FastScanner(new File("firesafe.in"));
            out = new PrintWriter(new File("firesafe.out"));
        }
        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

    }

    public static void main(String[] arg) throws IOException {
        new test().run();
    }

}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;

public class mai {

	public static int lowerBound(long[] array, int length, long value) {
		int low = 0;
		int high = length;
		while (low < high) {
			final int mid = (low + high) / 2;
			if (value <= array[mid]) {
				high = mid;
			} else {
				low = mid + 1;
			}
		}
		return low;
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static void sortbyColumn(int arr[][], int col) {
		// Using built-in sort function Arrays.sort
		Arrays.sort(arr, new Comparator<int[]>() {

			@Override
			// Compare values according to columns
			public int compare(final int[] entry1, final int[] entry2) {

				// To sort in descending order revert
				// the '>' Operator
				// if (entry1[col] > entry2[col])
				// return 1;
				// else //(entry1[col] >= entry2[col])
				// return -1;
				return new Integer(entry1[col]).compareTo(entry2[col]);
				// return entry1[col].
			}
		}); // End of function call sort().
	}

	class pair<X, Y> { // utilizing Java "Generics"
		X _first;
		Y _second;

		public pair(X f, Y s) {
			_first = f;
			_second = s;
		}

		X first() {
			return _first;
		}

		Y second() {
			return _second;
		}

		void setFirst(X f) {
			_first = f;
		}

		void setSecond(Y s) {
			_second = s;
		}
	}

	static long nCr(long n, long r) {
		long x = 1;
		long yu = n - r;
		while (n > r) {
			x = x * n;
			n--;
		}

		while (yu > 0) {
			x /= yu;
			yu--;
		}
		return x;
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		FastReader sc = new FastReader();
		// BufferedReader br = new BufferedReader(new
		// InputStreamReader(System.in));
		// Scanner scn = new Scanner(System.in);
		// PrintWriter pr = new PrintWriter(new BufferedWriter(new
		// OutputStreamWriter(System.out)));
		int n = sc.nextInt();
		int max = sc.nextInt();
		int arr[] = new int[n];
		HashMap<Integer, Integer> h = new HashMap<>();
		HashSet<Integer> uni = new HashSet<>();
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			if (h.containsKey(arr[i]))
				h.put(arr[i], h.get(arr[i]) + 1);
			else
				h.put(arr[i], 1);
			uni.add(arr[i]);
		}
		long pos = (long) Math.pow(2, max);
		if (h.size() <= pos) {
			System.out.println("0");
			return;
		}
		long red = h.size() - pos;
		Object[] unique = uni.toArray();
		Arrays.sort(unique);
		int c = 0;
		int i = 0, j = (unique.length - 1);
		//System.out.println(j+" "+uni);
		long sum = 0;
		while (c < red) {
			int a = h.get(unique[i]);
			int b = h.get(unique[j]);
			if (a < b) {
				i++;
				sum += a;
			} else {
				j--;
				sum += b;
			}
			c++;
		}
		System.out.println(sum);
	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;

public class mai {

	public static int lowerBound(long[] array, int length, long value) {
		int low = 0;
		int high = length;
		while (low < high) {
			final int mid = (low + high) / 2;
			if (value <= array[mid]) {
				high = mid;
			} else {
				low = mid + 1;
			}
		}
		return low;
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static void sortbyColumn(int arr[][], int col) {
		// Using built-in sort function Arrays.sort
		Arrays.sort(arr, new Comparator<int[]>() {

			@Override
			// Compare values according to columns
			public int compare(final int[] entry1, final int[] entry2) {

				// To sort in descending order revert
				// the '>' Operator
				// if (entry1[col] > entry2[col])
				// return 1;
				// else //(entry1[col] >= entry2[col])
				// return -1;
				return new Integer(entry1[col]).compareTo(entry2[col]);
				// return entry1[col].
			}
		}); // End of function call sort().
	}

	class pair<X, Y> { // utilizing Java "Generics"
		X _first;
		Y _second;

		public pair(X f, Y s) {
			_first = f;
			_second = s;
		}

		X first() {
			return _first;
		}

		Y second() {
			return _second;
		}

		void setFirst(X f) {
			_first = f;
		}

		void setSecond(Y s) {
			_second = s;
		}
	}

	static long nCr(long n, long r) {
		long x = 1;
		long yu = n - r;
		while (n > r) {
			x = x * n;
			n--;
		}

		while (yu > 0) {
			x /= yu;
			yu--;
		}
		return x;
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		FastReader sc = new FastReader();
		// BufferedReader br = new BufferedReader(new
		// InputStreamReader(System.in));
		// Scanner scn = new Scanner(System.in);
		// PrintWriter pr = new PrintWriter(new BufferedWriter(new
		// OutputStreamWriter(System.out)));
		int n = sc.nextInt();
		int max = sc.nextInt();
		int arr[] = new int[n];
		HashMap<Integer, Integer> h = new HashMap<>();
		HashSet<Integer> uni = new HashSet<>();
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			if (h.containsKey(arr[i]))
				h.put(arr[i], h.get(arr[i]) + 1);
			else
				h.put(arr[i], 1);
			uni.add(arr[i]);
		}
		long pos = (max*8)/n;
		pos=(long) Math.pow(2, pos);
		if (h.size() <= pos) {
			System.out.println("0");
			return;
		}
		long red = h.size() - pos;
		Object[] unique = uni.toArray();
		Arrays.sort(unique);
		int c = 0;
		// int i = 0, j = (unique.length - 1);
		// System.out.println(j+" "+uni);
		long sum = 0;
		long min = Integer.MAX_VALUE;
		for (int i = 0; i < red; i++) {
			sum += h.get(unique[i]);
		}
		min = sum;
		//System.out.println(sum);
		int j = unique.length - 1;
		for (int i = (int) (red - 1); i >= 0; i--) {
			sum = sum - (h.get(unique[i]));
			sum += h.get(unique[j]);
			if (sum < min)
				min = sum;
			j--;
		}
		System.out.println(min);
	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;

public class mai {

	public static int lowerBound(long[] array, int length, long value) {
		int low = 0;
		int high = length;
		while (low < high) {
			final int mid = (low + high) / 2;
			if (value <= array[mid]) {
				high = mid;
			} else {
				low = mid + 1;
			}
		}
		return low;
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static void sortbyColumn(int arr[][], int col) {
		// Using built-in sort function Arrays.sort
		Arrays.sort(arr, new Comparator<int[]>() {

			@Override
			// Compare values according to columns
			public int compare(final int[] entry1, final int[] entry2) {

				// To sort in descending order revert
				// the '>' Operator
				// if (entry1[col] > entry2[col])
				// return 1;
				// else //(entry1[col] >= entry2[col])
				// return -1;
				return new Integer(entry1[col]).compareTo(entry2[col]);
				// return entry1[col].
			}
		}); // End of function call sort().
	}

	class pair<X, Y> { // utilizing Java "Generics"
		X _first;
		Y _second;

		public pair(X f, Y s) {
			_first = f;
			_second = s;
		}

		X first() {
			return _first;
		}

		Y second() {
			return _second;
		}

		void setFirst(X f) {
			_first = f;
		}

		void setSecond(Y s) {
			_second = s;
		}
	}

	static long nCr(long n, long r) {
		long x = 1;
		long yu = n - r;
		while (n > r) {
			x = x * n;
			n--;
		}

		while (yu > 0) {
			x /= yu;
			yu--;
		}
		return x;
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		FastReader sc = new FastReader();
		// BufferedReader br = new BufferedReader(new
		// InputStreamReader(System.in));
		// Scanner scn = new Scanner(System.in);
		// PrintWriter pr = new PrintWriter(new BufferedWriter(new
		// OutputStreamWriter(System.out)));
		int n = sc.nextInt();
		int max = sc.nextInt();
		int arr[] = new int[n];
		HashMap<Integer, Integer> h = new HashMap<>();
		HashSet<Integer> uni = new HashSet<>();
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			if (h.containsKey(arr[i]))
				h.put(arr[i], h.get(arr[i]) + 1);
			else
				h.put(arr[i], 1);
			uni.add(arr[i]);
		}
		long pos = (long) Math.pow(2, max);
		if (h.size() <= pos) {
			System.out.println("0");
			return;
		}
		long red = h.size() - pos;
		Object[] unique = uni.toArray();
		int freq[] = new int[unique.length];
		for (int i = 0; i < unique.length; i++) {
			freq[i] = h.get(unique[i]);
		}
		Arrays.sort(freq);
		long sum = 0;
		for (int i = 0; i < red; i++) {
			sum+=freq[i];
		}
		System.out.println(sum);
	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;

public class mai {

	public static int lowerBound(long[] array, int length, long value) {
		int low = 0;
		int high = length;
		while (low < high) {
			final int mid = (low + high) / 2;
			if (value <= array[mid]) {
				high = mid;
			} else {
				low = mid + 1;
			}
		}
		return low;
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static void sortbyColumn(int arr[][], int col) {
		// Using built-in sort function Arrays.sort
		Arrays.sort(arr, new Comparator<int[]>() {

			@Override
			// Compare values according to columns
			public int compare(final int[] entry1, final int[] entry2) {

				// To sort in descending order revert
				// the '>' Operator
				// if (entry1[col] > entry2[col])
				// return 1;
				// else //(entry1[col] >= entry2[col])
				// return -1;
				return new Integer(entry1[col]).compareTo(entry2[col]);
				// return entry1[col].
			}
		}); // End of function call sort().
	}

	class pair<X, Y> { // utilizing Java "Generics"
		X _first;
		Y _second;

		public pair(X f, Y s) {
			_first = f;
			_second = s;
		}

		X first() {
			return _first;
		}

		Y second() {
			return _second;
		}

		void setFirst(X f) {
			_first = f;
		}

		void setSecond(Y s) {
			_second = s;
		}
	}

	static long nCr(long n, long r) {
		long x = 1;
		long yu = n - r;
		while (n > r) {
			x = x * n;
			n--;
		}

		while (yu > 0) {
			x /= yu;
			yu--;
		}
		return x;
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		FastReader sc = new FastReader();
		// BufferedReader br = new BufferedReader(new
		// InputStreamReader(System.in));
		// Scanner scn = new Scanner(System.in);
		// PrintWriter pr = new PrintWriter(new BufferedWriter(new
		// OutputStreamWriter(System.out)));
		int n = sc.nextInt();
		int max = sc.nextInt();
		int arr[] = new int[n];
		HashMap<Integer, Integer> h = new HashMap<>();
		HashSet<Integer> uni = new HashSet<>();
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			if (h.containsKey(arr[i]))
				h.put(arr[i], h.get(arr[i]) + 1);
			else
				h.put(arr[i], 1);
			uni.add(arr[i]);
		}
		long pos = (long) Math.pow(2, max);
		if (h.size() <= pos) {
			System.out.println("0");
			return;
		}
		long red = h.size() - pos;
		Object[] unique = uni.toArray();
		Arrays.sort(unique);
		int c = 0;
		// int i = 0, j = (unique.length - 1);
		// System.out.println(j+" "+uni);
		long sum = 0;
		long min = Integer.MAX_VALUE;
		for (int i = 0; i < red; i++) {
			sum += h.get(unique[i]);
		}
		min = sum;
		//System.out.println(sum);
		int j = unique.length - 1;
		for (int i = (int) (red - 1); i >= 0; i--) {
			sum = sum - (h.get(unique[i]));
			sum += h.get(unique[j]);
			if (sum < min)
				min = sum;
			j--;
		}
		System.out.println(min);
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMP3 solver = new CMP3();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMP3 {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), I = s.nextInt() * 8, pos = 1;
            int[] a = new int[n], f = new int[400005], dis = new int[400005];
            HashMap<Integer, Integer> h = new HashMap<>();
            TreeSet<Integer> t = new TreeSet<>();
            for (int i = 0; i < n; i++) {
                a[i] = s.nextInt();
                if (!h.containsKey(a[i])) h.put(a[i], 1);
                else h.replace(a[i], h.get(a[i]) + 1);
                t.add(a[i]);
            }
            for (int i : t) {
                f[pos] = h.get(i);
                dis[pos++] = 1;
            }
            for (int i = 1; i < 400005; i++) {
                f[i] += f[i - 1];
                dis[i] += dis[i - 1];
            }
            int l = 1, r = 400004, ans = 0;
            while (l < r) {
                int distinct = dis[r] - dis[l - 1], i;
                for (i = 0; i < 21; i++) {
                    if (distinct <= (1 << i)) {
                        break;
                    }
                }
                if (n * i <= I) {
                    break;
                } else {
                    if (f[l] - f[l - 1] <= f[r] - f[r - 1]) {
                        ans += f[l] - f[l - 1];
                        l++;
                    } else {
                        ans += f[r] - f[r - 1];
                        r--;
                    }
                }
            }
            w.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMP3 solver = new CMP3();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMP3 {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), I = s.nextInt() * 8, pos = 1;
            int[] a = new int[n], f = new int[400005], dis = new int[400005];
            HashMap<Integer, Integer> h = new HashMap<>();
            TreeSet<Integer> t = new TreeSet<>();
            for (int i = 0; i < n; i++) {
                a[i] = s.nextInt();
                if (!h.containsKey(a[i])) h.put(a[i], 1);
                else h.replace(a[i], h.get(a[i]) + 1);
                t.add(a[i]);
            }
            for (int i : t) {
                f[pos++] = h.get(i);
                dis[i] = 1;
            }
            for (int i = 1; i < 400001; i++) {
                f[i] += f[i - 1];
                dis[i] += dis[i - 1];
            }
            int l = 1, r = 400000;
            while (l < r) {
                int distinct = dis[r] - dis[l - 1];
                if ((long) (n * Math.ceil(Math.log(distinct) / Math.log(2))) <= I) {
                    break;
                } else {
                    if (f[l] - f[l - 1] <= f[r] - f[r - 1]) l++;
                    else r--;
                }
            }
            w.println(f[400000] - f[r] + f[l - 1]);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMP3 solver = new CMP3();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMP3 {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), I = s.nextInt() * 8;
            int[] a = new int[n], f = new int[400001], dis = new int[400001];
            for (int i = 0; i < n; i++) {
                a[i] = s.nextInt();
                f[a[i]]++;
                dis[a[i]] = 1;
            }
            for (int i = 1; i < 400001; i++) {
                f[i] += f[i - 1];
                dis[i] += dis[i - 1];
            }
            int l = 1, r = 400000;
            while (l < r) {
                int distinct = dis[r] - dis[l - 1];
                if ((long) (n * Math.ceil(Math.log(distinct) / Math.log(2))) <= I) {
                    break;
                } else {
                    if (f[l] - f[l - 1] <= f[r] - f[r - 1]) {
                        l++;
                    } else r--;
                }
                //if(r<=4) w.println(l+" "+r);
            }
            w.println(f[400000] - f[r] + f[l - 1]);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMP3 solver = new CMP3();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMP3 {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), I = s.nextInt() * 8, pos = 1;
            int[] a = new int[n], f = new int[400005], dis = new int[400005];
            HashMap<Integer, Integer> h = new HashMap<>();
            TreeSet<Integer> t = new TreeSet<>();
            for (int i = 0; i < n; i++) {
                a[i] = s.nextInt();
                if (!h.containsKey(a[i])) h.put(a[i], 1);
                else h.replace(a[i], h.get(a[i]) + 1);
                t.add(a[i]);
            }
            for (int i : t) {
                f[pos] = h.get(i);
                dis[pos++] = 1;
            }
            for (int i = 1; i < 400001; i++) {
                f[i] += f[i - 1];
                dis[i] += dis[i - 1];
            }
            int l = 1, r = 400000;
            while (l < r) {
                int distinct = dis[r] - dis[l - 1];
                if ((long) (n * Math.ceil(Math.log(distinct) / Math.log(2))) <= I) {
                    break;
                } else {
                    if (f[l] - f[l - 1] <= f[r] - f[r - 1]) l++;
                    else r--;
                }
            }
            w.println(f[400000] - f[r] + f[l - 1]);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMP3 solver = new CMP3();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMP3 {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), I = s.nextInt() * 8, pos = 1;
            int[] a = new int[n], f = new int[400005];
            HashMap<Integer, Integer> h = new HashMap<>();
            TreeSet<Integer> t = new TreeSet<>();
            for (int i = 0; i < n; i++) {
                a[i] = s.nextInt();
                if (!h.containsKey(a[i])) h.put(a[i], 1);
                else h.replace(a[i], h.get(a[i]) + 1);
                t.add(a[i]);
            }
            for (int i : t) {
                f[pos++] = h.get(i);
            }
            for (int i = 1; i < 400005; i++) {
                f[i] += f[i - 1];
            }
            for (int i = pos; i >= 1; i--) {
                int j;
                for (j = 0; j < 21; j++) {
                    if ((1 << j) >= i) {
                        break;
                    }
                }
                if (j * n <= I) {
                    int max = 0;
                    //w.println(i);
                    for (int k = i; k <= pos; k++) {
                        max = Math.max(max, f[k] - f[k - i]);
                    }
                    w.println(f[pos] - max);
                    return;
                }
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMP3 solver = new CMP3();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMP3 {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), I = s.nextInt() * 8, pos = 1;
            int[] a = new int[n], f = new int[400005], dis = new int[400005];
            HashMap<Integer, Integer> h = new HashMap<>();
            TreeSet<Integer> t = new TreeSet<>();
            for (int i = 0; i < n; i++) {
                a[i] = s.nextInt();
                if (!h.containsKey(a[i])) h.put(a[i], 1);
                else h.replace(a[i], h.get(a[i]) + 1);
                t.add(a[i]);
            }
            for (int i : t) {
                f[pos] = h.get(i);
                dis[pos++] = 1;
            }
            for (int i = 1; i < 400005; i++) {
                f[i] += f[i - 1];
                dis[i] += dis[i - 1];
            }
            int l = 1, r = 400004;
            while (l < r) {
                int distinct = dis[r] - dis[l - 1];
                if ((long) (n * Math.ceil(Math.log(distinct) / Math.log(2))) <= I) {
                    break;
                } else {
                    if (f[l] - f[l - 1] <= f[r] - f[r - 1]) l++;
                    else r--;
                }
            }
            w.println(f[400004] - f[r] + f[l - 1]);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMP3 solver = new CMP3();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMP3 {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), I = s.nextInt() * 8, pos = 1;
            int[] a = new int[n], f = new int[400005], dis = new int[400005];
            HashMap<Integer, Integer> h = new HashMap<>();
            TreeSet<Integer> t = new TreeSet<>();
            for (int i = 0; i < n; i++) {
                a[i] = s.nextInt();
                if (!h.containsKey(a[i])) h.put(a[i], 1);
                else h.replace(a[i], h.get(a[i]) + 1);
                t.add(a[i]);
            }
            for (int i : t) {
                f[pos] = h.get(i);
                dis[pos++] = 1;
            }
            for (int i = 1; i < 400005; i++) {
                f[i] += f[i - 1];
                dis[i] += dis[i - 1];
            }
            int l = 1, r = 400004;
            while (l < r) {
                int distinct = dis[r] - dis[l - 1], i;
                for (i = 0; i < 21; i++) {
                    if (distinct <= (1 << i)) {
                        break;
                    }
                }
                if (n * i <= I) {
                    break;
                } else {
                    if (f[l] - f[l - 1] <= f[r] - f[r - 1]) l++;
                    else r--;
                }
            }
            w.println(f[400004] - f[r] + f[l - 1]);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;

public class Main {
	static StreamTokenizer st=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	public static void main(String[] args) {
		int n=nextInt();
		int I=nextInt();
		int k=8*I/n;
		long K;
		int a[]=new int[n+1];
		int num[]=new int[n+1];
		int cnt=0;
		for(int i=1;i<=n;i++){
			a[n+1-i]=nextInt();
		}
		Arrays.sort(a,1,n+1);
		a[0]=-1;
		for(int i=1;i<=n;i++){
			if(a[i]!=a[i-1])
				num[++cnt]=i;
		}
		K=(int)(Math.log((double)(a[n]-a[1]))/Math.log(2.0));
		if(K<k){
			System.out.println(0);
		}else{
			int ans=n;
			for(int i=1;i<cnt;i++){
				int c=i+(1<<k)-1;
				if(c>cnt)
					break;
				ans=Math.min(ans, n-num[c]+num[i-1]);
			}
			System.out.println(ans);
		}
	}
	static int nextInt(){
		try {
			st.nextToken();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return (int)st.nval;
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;

public class Main{
	static StreamTokenizer st=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	public static void main(String[] args) {
		int n=nextInt();
		int I=nextInt();
		int k=8*I/n;
		long K;
		int a[]=new int[n+1];
		int num[]=new int[n+1];
		int cnt=0;
		for(int i=1;i<=n;i++){
			a[i]=nextInt();
		}
		Arrays.sort(a,1,n+1);
		a[0]=-1;
		for(int i=1;i<=n;i++){
			if(a[i]!=a[i-1])
				num[++cnt]=i;
		}
		K=(int)(Math.log((double)(a[n]-a[1]))/Math.log(2.0));
		if(K<k){
			System.out.println(0);
		}else{
			int ans=n;
			for(int i=1;i<cnt;i++){
				int c=i+(1<<k)-1;
				if(c>cnt)
					break;
				ans=Math.min(ans, n-num[c]+num[i-1]);
			}
			System.out.println(ans);
		}
	}
	static int nextInt(){
		try {
			st.nextToken();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return (int)st.nval;
	}
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
TreeMap<Integer,Integer>map=new TreeMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
	int min=Integer.MAX_VALUE;
	long tot=I*8;int f=n;
for(int h:map.values())
{
	list.add(h);

}

Collections.sort(list);
int sz=list.size();long q=n;
long u=(long) Math.ceil(Math.log10(sz)/Math.log10(2));
if(u*q>tot)
for(int h:list)
{
	long val=(long) Math.ceil(Math.log10(sz)/Math.log10(2L));

	min=Math.min(min, f-h);
	f-=h;

	sz--;
	if((val*q)<=tot)
		break;

}
if(min==Integer.MAX_VALUE)
	System.out.println(0);
else if(min==0)
	System.out.println(n);
else
System.out.println(min);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
HashMap<Integer,Integer>map=new HashMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
	long tot=8L*I;
	for(int h:map.values())
		list.add(h);
	Collections.sort(list);
	long ans=0;long sz=list.size();
			for(int h:list)
			{
				long val=(long) Math.ceil(Math.log10(sz)/Math.log10(2L));
				if((val*n)>tot)
				{
					ans+=h;
					sz--;

				}
				else break;

			}
	System.out.println(ans);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
TreeMap<Integer,Integer>map=new TreeMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
	long tot=8L*I;
	for(int h:map.keySet())
	list.add(h);
	Collections.sort(list);
	long ans=0;
	long q=(long) Math.floor(8*I/n);
	q=(long) Math.pow(2,q);
	long sum=0;
	for(int i=0;i<q;i++)
		sum+=map.get(list.get(i));

	int max=0;
	for(int i=(int) q;i<list.size();i++)
	{
		sum=sum-map.get(list.get((int) (i-q)))+map.get(list.get(i));

		max=(int) Math.max(sum, max);
	}
	System.out.println(n-max);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
TreeMap<Integer,Integer>map=new TreeMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
	long tot=8L*I;
	for(int h:map.keySet())
	list.add(h);
	Collections.sort(list);
	long ans=0;
	long q=(long) Math.floor(8*I/n);
	q=(long) Math.pow(2,q);
	long sum=0;
	for(int i=0;i<q;i++)
		sum+=map.get(list.get(i));

	int max=0;
	for(int i=(int) q;i<list.size();i++)
	{
		sum=sum-map.get(list.get((int) (i-q)))+map.get(list.get(i));

		max=(int) Math.max(sum, max);
	}
	if(max==0)
		System.out.println(0);
	else
	System.out.println(n-max);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

import jabfh.lkweuf.Pair;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
TreeMap<Integer,Integer>map=new TreeMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
	int min=Integer.MAX_VALUE;
	long tot=I*8;int f=n;
for(int h:map.values())
{
	list.add(h);

}
Collections.sort(list);
int sz=list.size();int q=sz;
for(int h:list)
{
	long val=(long) Math.ceil(Math.log10(sz)/Math.log10(2));
	if((val*sz)<=I)
		break;
	min=Math.min(min, f-h);
	f-=h;
	sz--;

}
if(min==q)
	System.out.println(0);
else
System.out.println(min);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
TreeMap<Integer,Integer>map=new TreeMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
	int min=0;
	long tot=I*8;int f=n;
for(int h:map.values())
{
	list.add(h);

}

Collections.sort(list);int w=0;
int sz=list.size();long q=n;
long u=(long) Math.ceil(Math.log10(sz)/Math.log10(2));
if(u*q>tot)
for(int h:list)
{
	long val=(long) Math.ceil(Math.log10(sz)/Math.log10(2L));
w+=h;
	min=Math.max(min, w);

	sz--;
	if((val*q)<=tot)
		break;

}

if(min==0)
	System.out.println(0);
else
System.out.println(n-min);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
TreeMap<Integer,Integer>map=new TreeMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
	long tot=8L*I;
	for(int h:map.keySet())
	list.add(h);
	int l=0;int r=list.size()-1;int sz=list.size();long ans=0;
	while(l<r)
	{
		long val=(long) Math.ceil(Math.log10(sz)/Math.log10(2));
		if(val*n>tot)
		{
			if(map.get(list.get(l))<map.get(list.get(r)))
				{
				ans+=map.get(list.get(l));l++;
				}
			else
				{
				ans+=map.get(list.get(r));r--;
				}
		}
		else
			break;
		sz--;
	}

	System.out.println(ans);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
TreeMap<Integer,Integer>map=new TreeMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
		if(8*I>=n*(Math.ceil(Math.log10(map.size())/Math.log10(2))))
			{
			System.out.println(0);return;
			}
	long tot=8L*I;
	for(int h:map.keySet())
	list.add(h);
	Collections.sort(list);
	long ans=0;
	long q=(long) Math.floor(8*I/n);
	q=(long) Math.pow(2,q);

	long sum=0;
	for(int i=0;i<q;i++)
		sum+=map.get(list.get(i));

	int max=0;
	for(int i=(int) q;i<list.size();i++)
	{
		sum=sum-map.get(list.get((int) (i-q)))+map.get(list.get(i));

		max=(int) Math.max(sum, max);
	}
	if(max==0)
		System.out.println(0);
	else
	System.out.println(n-max);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
HashMap<Integer,Integer>map=new HashMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
	long tot=8*I;
	for(int h:map.values())
		list.add(h);
	Collections.sort(list);
	int ans=0;int sz=list.size();
			for(int h:list)
			{
				long val=(long) Math.ceil(Math.log10(sz)/Math.log10(2));
				if(val*n>tot)
				{
					ans+=h;
					sz--;

				}
				else break;

			}
	System.out.println(ans);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
TreeMap<Integer,Integer>map=new TreeMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
	int min=Integer.MAX_VALUE;
	long tot=I*8;int f=n;
for(int h:map.values())
{
	list.add(h);

}
Collections.sort(list);
int sz=list.size();int q=sz;
for(int h:list)
{
	long val=(long) Math.ceil(Math.log10(sz)/Math.log10(2));
	if((val*sz)<=I)
		break;
	min=Math.min(min, f-h);
	f-=h;
	sz--;

}
if(min==q)
	System.out.println(0);
else
System.out.println(min);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
TreeMap<Integer,Integer>map=new TreeMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
		if(n==1)
			{
			System.out.println(0);return;
			}
	long tot=8L*I;
	for(int h:map.keySet())
	list.add(h);
	Collections.sort(list);
	long ans=0;
	long q=(long) Math.floor(8*I/n);
	q=(long) Math.pow(2,q);

	long sum=0;
	for(int i=0;i<q;i++)
		sum+=map.get(list.get(i));

	int max=0;
	for(int i=(int) q;i<list.size();i++)
	{
		sum=sum-map.get(list.get((int) (i-q)))+map.get(list.get(i));

		max=(int) Math.max(sum, max);
	}
	if(max==0)
		System.out.println(0);
	else
	System.out.println(n-max);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class bits {
    public static class FastReader {
			BufferedReader br;
			StringTokenizer st;
			//it reads the data about the specified point and divide the data about it ,it is quite fast
			//than using direct

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());//converts string to integer
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception r) {
					r.printStackTrace();
				}
				return str;
			}
		}

		public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	static int ans=0;static int ar[]=new int[501];
static void bit(String a,String b)
{int ct=0;
	for(int i=0;i<a.length();i++)
	{
		if(a.charAt(i)=='1'||b.charAt(i)=='1')
			ct++;
	}
	ans=Math.max(ans, ct);
	ar[ct]++;

}
static class Pair implements Comparable<Pair>{
    int x;int y;
    Pair(int x,int y){
        this.x=x;
        this.y=y;
      //  this.i=i;
    }
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return x-o.x;

	}
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
TreeMap<Integer,Integer>map=new TreeMap<Integer,Integer>();
ArrayList<Integer>list=new ArrayList<Integer>();
		FastReader in=new FastReader();

		int n=in.nextInt();
		int I=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
		}
	int min=Integer.MAX_VALUE;
	long tot=I*8;int f=n;
for(int h:map.values())
{
	list.add(h);

}

Collections.sort(list);
int sz=list.size();long q=n;
long u=(long) Math.ceil(Math.log10(sz)/Math.log10(2));
if(u*q>tot)
for(int h:list)
{
	long val=(long) Math.ceil(Math.log10(sz)/Math.log10(2L));

	min=Math.min(min, f-h);
	f-=h;

	sz--;
	if((val*q)<=tot)
		break;

}
if(min==Integer.MAX_VALUE)
	System.out.println(0);
else
System.out.println(min);

	}

}