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=n;
long val=(long) Math.ceil(Math.log10(sz)/Math.log10(2));
if(val*q>tot)
for(int h:list)
{
	 val=(long) Math.ceil(Math.log10(sz)/Math.log10(2));

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

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

}
if(min==Integer.MAX_VALUE)
	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);
		}
	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.*;
import java.util.function.Supplier;
import java.util.*;

public class Mp3 {
    static Supplier<InputStream> inputSupplier = () -> new BufferedInputStream(System.in);
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(inputSupplier.get());
        PrintWriter out = outSupplier.get();
        int n = sc.nextInt();
        int nBytes = sc.nextInt();
        int nBits = nBytes*8;
        int bitsPerSample = nBits/n;
        int possibleDiffValues = (int)Math.pow(2, bitsPerSample);

        Map.Entry<Integer, Integer>[] counts = getWordCounts(sc, n);
        Arrays.sort(counts, Comparator.comparingInt(e -> e.getKey()));
        int result = 0;
        if(possibleDiffValues<counts.length) {
            result = n - getSubarrayMax(counts, possibleDiffValues);
        }
        out.println(result);
        sc.close();
        out.close();
    }

    /* len = 1
    0 1 2 3 4 5 6 7
    1 2 3 3 4 3 2 1
  p   *
  q   *
     */
    private static int getSubarrayMax(Map.Entry<Integer, Integer>[] counts, int subarrayLen) {
        int p = 0, q=0;
        int n = counts.length;
        int curr = 0;
        while(q<subarrayLen && q < n) {
            curr += counts[q++].getValue();
        }
        int max = curr;
        q--;
        while(q < n-1) {
            curr += counts[++q].getValue();
            curr -= counts[p++].getValue();
            max = Math.max(max, curr);
        }
        return max;
    }

    private static Map.Entry<Integer, Integer>[] getWordCounts(Scanner sc, int n) throws IOException {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            int cnt = map.getOrDefault(v, 0);
            map.put(v, cnt+1);
        }

        Map.Entry<Integer, Integer>[] counts = new Map.Entry[map.size()];
        int i = 0;
        for (Map.Entry<Integer, Integer> c: map.entrySet()) {
            counts[i++] = c;
        }
        return counts;
    }
}


import java.io.*;
import java.util.function.Supplier;
import java.util.*;

public class Mp3 {
    static Supplier<BufferedReader> inputSupplier = () -> new BufferedReader(new InputStreamReader(System.in));
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(inputSupplier.get());
        PrintWriter out = outSupplier.get();
        int n = sc.nextInt();
        int nBytes = sc.nextInt();
        int nBits = nBytes*8;
        int bitsPerSample = nBits/n;
        int possibleDiffValues = (int)Math.pow(2, bitsPerSample);

        Map.Entry<Integer, Integer>[] counts = getWordCounts(sc, n);
        Arrays.sort(counts, Comparator.comparingInt(e -> e.getKey()));
        int result = 0;
        if(possibleDiffValues<counts.length) {
            result = n - getSubarrayMax(counts, possibleDiffValues);
        }
        out.println(result);
        sc.close();
        out.close();
    }

    /* len = 1
    0 1 2 3 4 5 6 7
    1 2 3 3 4 3 2 1
  p   *
  q   *
     */
    private static int getSubarrayMax(Map.Entry<Integer, Integer>[] counts, int subarrayLen) {
        int p = 0, q=0;
        int n = counts.length;
        int curr = 0;
        while(q<subarrayLen && q < n) {
            curr += counts[q++].getValue();
        }
        int max = curr;
        q--;
        while(q < n-1) {
            curr += counts[++q].getValue();
            curr -= counts[p++].getValue();
            max = Math.max(max, curr);
        }
        return max;
    }

    private static Map.Entry<Integer, Integer>[] getWordCounts(Scanner sc, int n) throws IOException {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            int cnt = map.getOrDefault(v, 0);
            map.put(v, cnt+1);
        }

        Map.Entry<Integer, Integer>[] counts = new Map.Entry[map.size()];
        int i = 0;
        for (Map.Entry<Integer, Integer> c: map.entrySet()) {
            counts[i++] = c;
        }
        return counts;
    }
}


import java.io.*;
import java.util.function.Supplier;
import java.util.*;

public class Mp3 {
    static Supplier<InputStream> inputSupplier = () -> System.in;
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(inputSupplier.get()));
        StringTokenizer tok = new StringTokenizer(in.readLine());
        PrintWriter out = outSupplier.get();
        int n = Integer.parseInt(tok.nextToken());
        int nBytes = Integer.parseInt(tok.nextToken());
        int nBits = nBytes*8;
        int bitsPerSample = nBits/n;
        int possibleDiffValues = (int)Math.pow(2, bitsPerSample);

        Map.Entry<Integer, Integer>[] counts = getWordCounts(in, n);

        int result = 0;
        if(possibleDiffValues<counts.length) {
            result = n - getSubarrayMax(counts, possibleDiffValues);
        }
        out.println(result);
        in.close();
        out.close();
    }

    /* len = 1
    0 1 2 3 4 5 6 7
    1 2 3 3 4 3 2 1
  p   *
  q   *
     */
    private static int getSubarrayMax(Map.Entry<Integer, Integer>[] counts, int subarrayLen) {
        int p = 0, q=0;
        int n = counts.length;
        int curr = 0;
        while(q<subarrayLen && q < n) {
            curr += counts[q++].getValue();
        }
        int max = curr;
        q--;
        while(q < n-1) {
            curr += counts[++q].getValue();
            curr -= counts[p++].getValue();
            max = Math.max(max, curr);
        }
        return max;
    }

    private static Map.Entry<Integer, Integer>[] getWordCounts(BufferedReader in, int n) throws IOException {
        StringTokenizer tok = new StringTokenizer(in.readLine());
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int v = Integer.parseInt(tok.nextToken());
            int cnt = map.getOrDefault(v, 0);
            map.put(v, cnt+1);
        }

        Map.Entry<Integer, Integer>[] counts = new Map.Entry[map.size()];
        int i = 0;
        for (Map.Entry<Integer, Integer> c: map.entrySet()) {
            counts[i++] = c;
        }
        return counts;
    }
}


import java.io.InputStream;
import java.io.PrintWriter;
import java.util.function.Supplier;
import java.util.*;

public class Mp3 {
    static Supplier<InputStream> inputSupplier = () -> System.in;
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(inputSupplier.get());
        PrintWriter out = outSupplier.get();
        int n = sc.nextInt();
        int nBytes = sc.nextInt();
        int nBits = nBytes*8;
        int bitsPerSample = nBits/n;
        int possibleDiffValues = (int)Math.pow(2, bitsPerSample);

        Map.Entry<Integer, Integer>[] counts = getWordCounts(sc, n);

        Arrays.sort(counts, Comparator.comparingInt( e -> e.getKey()));

        int result = n-getSubarrayMax(counts, possibleDiffValues);

        out.println(result);
        sc.close();
        out.close();
    }

    /* len = 1
    0 1 2 3 4 5 6 7
    1 2 3 3 4 3 2 1
  p   *
  q   *
     */
    private static int getSubarrayMax(Map.Entry<Integer, Integer>[] counts, int subarrayLen) {
        int p = 0, q=0;
        int n = counts.length;
        int curr = 0;
        while(q<subarrayLen && q < n) {
            curr += counts[q++].getValue();
        }
        int max = curr;
        q--;
        while(q < n-1) {
            curr += counts[++q].getValue();
            curr -= counts[p++].getValue();
            max = Math.max(max, curr);
        }
        return max;
    }

    private static Map.Entry<Integer, Integer>[] getWordCounts(Scanner sc, int n) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            int cnt = map.getOrDefault(v, 0);
            map.put(v, cnt+1);
        }

        Map.Entry<Integer, Integer>[] counts = new Map.Entry[map.size()];
        int i = 0;
        for (Map.Entry<Integer, Integer> c: map.entrySet()) {
            counts[i++] = c;
        }
        return counts;
    }
}


import java.io.InputStream;
import java.io.PrintWriter;
import java.util.function.Supplier;
import java.util.*;

public class Mp3 {
    static Supplier<InputStream> inputSupplier = () -> System.in;
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(inputSupplier.get());
        PrintWriter out = outSupplier.get();
        int n = sc.nextInt();
        int nBytes = sc.nextInt();
        int nBits = nBytes*8;
        int bitsPerSample = nBits/n;
        int possibleDiffValues = (int)Math.pow(2, bitsPerSample);

        Map.Entry<Integer, Integer>[] counts = getWordCounts(sc, n);

        int result = 0;
        if(possibleDiffValues<counts.length) {
            Arrays.sort(counts, Comparator.comparingInt(e -> e.getKey()));
            result = n - getSubarrayMax(counts, possibleDiffValues);
        }
        out.println(result);
        sc.close();
        out.close();
    }

    /* len = 1
    0 1 2 3 4 5 6 7
    1 2 3 3 4 3 2 1
  p   *
  q   *
     */
    private static int getSubarrayMax(Map.Entry<Integer, Integer>[] counts, int subarrayLen) {
        int p = 0, q=0;
        int n = counts.length;
        int curr = 0;
        while(q<subarrayLen && q < n) {
            curr += counts[q++].getValue();
        }
        int max = curr;
        q--;
        while(q < n-1) {
            curr += counts[++q].getValue();
            curr -= counts[p++].getValue();
            max = Math.max(max, curr);
        }
        return max;
    }

    private static Map.Entry<Integer, Integer>[] getWordCounts(Scanner sc, int n) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            int cnt = map.getOrDefault(v, 0);
            map.put(v, cnt+1);
        }

        Map.Entry<Integer, Integer>[] counts = new Map.Entry[map.size()];
        int i = 0;
        for (Map.Entry<Integer, Integer> c: map.entrySet()) {
            counts[i++] = c;
        }
        return counts;
    }
}


import java.io.InputStream;
import java.io.PrintWriter;
import java.util.function.Supplier;
import java.util.*;

public class Mp3 {
    static Supplier<InputStream> inputSupplier = () -> System.in;
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(inputSupplier.get());
        PrintWriter out = outSupplier.get();
        int n = sc.nextInt();
        int ibytes = sc.nextInt();
        int bits = ibytes*8;
        int bitsPerSample = bits/n;
        int diffValues = (int)Math.pow(2, bitsPerSample);

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            int cnt = map.getOrDefault(v, 0);
            map.put(v, cnt+1);
        }

        int[] counts = new int[map.size()];
        int i = 0;
        for (int c: map.values()) {
            counts[i++] = c;
        }
        Arrays.sort(counts);

        int result = 0;
        for (i = counts.length - 1; i >= 0; i--) {
            if (diffValues > 0) {
                diffValues--;
            } else {
                result += counts[i];
            }
        }

        out.println(result);
        sc.close();
        out.close();
    }
}


public class Mp3 {
    static Supplier<InputStream> inputSupplier = () -> System.in;
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(inputSupplier.get()));
        StringTokenizer tok = new StringTokenizer(in.readLine());
        PrintWriter out = outSupplier.get();
        int n = Integer.parseInt(tok.nextToken());
        int nBytes = Integer.parseInt(tok.nextToken());
        int nBits = nBytes*8;
        int bitsPerSample = nBits/n;
        int possibleDiffValues = (int)Math.pow(2, bitsPerSample);

        TreeMap<Integer, Integer> counts = getWordCounts(in, n);
        int[] arr = new int[counts.size()];
        int i = 0;
        for (int c : counts.values()) {
            arr[i++] = c;
        }

        int result = 0;
        if(possibleDiffValues<counts.size()) {
            result = n - getSubarrayMax(arr, possibleDiffValues);
        }
        out.println(result);
        in.close();
        out.close();
    }

    /* len = 1
    0 1 2 3 4 5 6 7
    1 2 3 3 4 3 2 1
  p   *
  q   *
     */
    private static int getSubarrayMax(int[] counts, int subarrayLen) {
        int p = 0, q=0;
        int n = counts.length;
        int curr = 0;
        while(q<subarrayLen && q < n) {
            curr += counts[q++];
        }
        int max = curr;
        q--;
        while(q < n-1) {
            curr += counts[++q];
            curr -= counts[p++];
            max = Math.max(max, curr);
        }
        return max;
    }

    private static TreeMap<Integer, Integer> getWordCounts(BufferedReader in, int n) throws IOException {
        StringTokenizer tok = new StringTokenizer(in.readLine());
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int v = Integer.parseInt(tok.nextToken());
            map.putIfAbsent(v, 0);
            map.put(v, map.get(v)+1);
        }

        return map;
    }
}


import java.io.InputStream;
import java.io.PrintWriter;
import java.util.function.Supplier;
import java.util.*;

public class Mp3 {
    static Supplier<InputStream> inputSupplier = () -> System.in;
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(inputSupplier.get());
        PrintWriter out = outSupplier.get();
        int n = sc.nextInt();
        int nBytes = sc.nextInt();
        int nBits = nBytes*8;
        int bitsPerSample = nBits/n;
        int possibleDiffValues = (int)Math.pow(2, bitsPerSample);

        List<Map.Entry<Integer, Integer>> counts = getWordCounts(sc, n);

        int result = 0;
        if(possibleDiffValues<counts.size()) {
            Collections.sort(counts, Comparator.comparingInt(e -> e.getKey()));
            result = n - getSubarrayMax(counts, possibleDiffValues);
        }
        out.println(result);
        sc.close();
        out.close();
    }

    /* len = 1
    0 1 2 3 4 5 6 7
    1 2 3 3 4 3 2 1
  p   *
  q   *
     */
    private static int getSubarrayMax(List<Map.Entry<Integer, Integer>> counts, int subarrayLen) {
        int p = 0, q=0;
        int n = counts.size();
        int curr = 0;
        while(q<subarrayLen && q < n) {
            curr += counts.get(q++).getValue();
        }
        int max = curr;
        q--;
        while(q < n-1) {
            curr += counts.get(++q).getValue();
            curr -= counts.get(p++).getValue();
            max = Math.max(max, curr);
        }
        return max;
    }

    private static List<Map.Entry<Integer, Integer>> getWordCounts(Scanner sc, int n) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            int cnt = map.getOrDefault(v, 0);
            map.put(v, cnt+1);
        }

        List<Map.Entry<Integer, Integer>> counts = new ArrayList<>();
        for (Map.Entry<Integer, Integer> c: map.entrySet()) {
            counts.add(c);
        }
        return counts;
    }
}


import java.io.InputStream;
import java.io.PrintWriter;
import java.util.function.Supplier;
import java.util.*;

public class Mp3 {
    static Supplier<InputStream> inputSupplier = () -> System.in;
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(inputSupplier.get());
        PrintWriter out = outSupplier.get();
        int n = sc.nextInt();
        int nBytes = sc.nextInt();
        int nBits = nBytes*8;
        int bitsPerSample = nBits/n;
        int possibleDiffValues = (int)Math.pow(2, bitsPerSample);

        TreeMap<Integer, Integer> counts = getWordCounts(sc, n);
        int[] arr = new int[counts.size()];
        int i = 0;
        for (int c : counts.values()) {
            arr[i++] = c;
        }

        int result = 0;
        if(possibleDiffValues<counts.size()) {
            result = n - getSubarrayMax(arr, possibleDiffValues);
        }
        out.println(result);
        sc.close();
        out.close();
    }

    /* len = 1
    0 1 2 3 4 5 6 7
    1 2 3 3 4 3 2 1
  p   *
  q   *
     */
    private static int getSubarrayMax(int[] counts, int subarrayLen) {
        int p = 0, q=0;
        int n = counts.length;
        int curr = 0;
        while(q<subarrayLen && q < n) {
            curr += counts[q++];
        }
        int max = curr;
        q--;
        while(q < n-1) {
            curr += counts[++q];
            curr -= counts[p++];
            max = Math.max(max, curr);
        }
        return max;
    }

    private static TreeMap<Integer, Integer> getWordCounts(Scanner sc, int n) {
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            map.putIfAbsent(v, 0);
            map.put(v, map.get(v)+1);
        }

        return map;
    }
}


import java.io.*;
import java.util.function.Supplier;
import java.util.*;

public class Mp3 {
    static Supplier<InputStream> inputSupplier = () -> System.in;
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(inputSupplier.get()));
        StringTokenizer tok = new StringTokenizer(in.readLine());
        PrintWriter out = outSupplier.get();
        int n = Integer.parseInt(tok.nextToken());
        int nBytes = Integer.parseInt(tok.nextToken());
        int nBits = nBytes*8;
        int bitsPerSample = nBits/n;
        int possibleDiffValues = (int)Math.pow(2, bitsPerSample);

        Map.Entry<Integer, Integer>[] counts = getWordCounts(in, n);
        Arrays.sort(counts, Comparator.comparingInt(e -> e.getKey()));
        int result = 0;
        if(possibleDiffValues<counts.length) {
            result = n - getSubarrayMax(counts, possibleDiffValues);
        }
        out.println(result);
        in.close();
        out.close();
    }

    /* len = 1
    0 1 2 3 4 5 6 7
    1 2 3 3 4 3 2 1
  p   *
  q   *
     */
    private static int getSubarrayMax(Map.Entry<Integer, Integer>[] counts, int subarrayLen) {
        int p = 0, q=0;
        int n = counts.length;
        int curr = 0;
        while(q<subarrayLen && q < n) {
            curr += counts[q++].getValue();
        }
        int max = curr;
        q--;
        while(q < n-1) {
            curr += counts[++q].getValue();
            curr -= counts[p++].getValue();
            max = Math.max(max, curr);
        }
        return max;
    }

    private static Map.Entry<Integer, Integer>[] getWordCounts(BufferedReader in, int n) throws IOException {
        StringTokenizer tok = new StringTokenizer(in.readLine());
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int v = Integer.parseInt(tok.nextToken());
            int cnt = map.getOrDefault(v, 0);
            map.put(v, cnt+1);
        }

        Map.Entry<Integer, Integer>[] counts = new Map.Entry[map.size()];
        int i = 0;
        for (Map.Entry<Integer, Integer> c: map.entrySet()) {
            counts[i++] = c;
        }
        return counts;
    }
}


import java.io.*;
import java.util.function.Supplier;
import java.util.*;

public class Mp3 {
    static Supplier<InputStream> inputSupplier = () -> System.in;
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(inputSupplier.get()));
        StringTokenizer tok = new StringTokenizer(in.readLine());
        PrintWriter out = outSupplier.get();
        int n = Integer.parseInt(tok.nextToken());
        int nBytes = Integer.parseInt(tok.nextToken());
        int nBits = nBytes*8;
        int bitsPerSample = nBits/n;
        int possibleDiffValues = (int)Math.pow(2, bitsPerSample);

        TreeMap<Integer, Integer> counts = getWordCounts(in, n);
        int[] arr = new int[counts.size()];
        int i = 0;
        for (int c : counts.values()) {
            arr[i++] = c;
        }

        int result = 0;
        if(possibleDiffValues<counts.size()) {
            result = n - getSubarrayMax(arr, possibleDiffValues);
        }
        out.println(result);
        in.close();
        out.close();
    }

    /* len = 1
    0 1 2 3 4 5 6 7
    1 2 3 3 4 3 2 1
  p   *
  q   *
     */
    private static int getSubarrayMax(int[] counts, int subarrayLen) {
        int p = 0, q=0;
        int n = counts.length;
        int curr = 0;
        while(q<subarrayLen && q < n) {
            curr += counts[q++];
        }
        int max = curr;
        q--;
        while(q < n-1) {
            curr += counts[++q];
            curr -= counts[p++];
            max = Math.max(max, curr);
        }
        return max;
    }

    private static TreeMap<Integer, Integer> getWordCounts(BufferedReader in, int n) throws IOException {
        StringTokenizer tok = new StringTokenizer(in.readLine());
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int v = Integer.parseInt(tok.nextToken());
            map.putIfAbsent(v, 0);
            map.put(v, map.get(v)+1);
        }

        return map;
    }
}


import java.io.InputStream;
import java.io.PrintWriter;
import java.util.function.Supplier;
import java.util.*;

public class Mp3 {
    static Supplier<InputStream> inputSupplier = () -> System.in;
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(inputSupplier.get());
        PrintWriter out = outSupplier.get();
        int n = sc.nextInt();
        int nBytes = sc.nextInt();
        int nBits = nBytes*8;
        int bitsPerSample = nBits/n;
        int possibleDiffValues = (int)Math.pow(2, bitsPerSample);

        TreeMap<Integer, Integer> counts = getWordCounts(sc, n);
        int[] arr = new int[counts.size()];
        int i = 0;
        for (int c : counts.values()) {
            arr[i++] = c;
        }

        int result = 0;
        if(possibleDiffValues<counts.size()) {
            result = n - getSubarrayMax(arr, possibleDiffValues);
        }
        out.println(result);
        sc.close();
        out.close();
    }

    /* len = 1
    0 1 2 3 4 5 6 7
    1 2 3 3 4 3 2 1
  p   *
  q   *
     */
    private static int getSubarrayMax(int[] counts, int subarrayLen) {
        int p = 0, q=0;
        int n = counts.length;
        int curr = 0;
        while(q<subarrayLen && q < n) {
            curr += counts[q++];
        }
        int max = curr;
        q--;
        while(q < n-1) {
            curr += counts[++q];
            curr -= counts[p++];
            max = Math.max(max, curr);
        }
        return max;
    }

    private static TreeMap<Integer, Integer> getWordCounts(Scanner sc, int n) {
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            int cnt = map.getOrDefault(v, 0);
            map.put(v, cnt+1);
        }

        return map;
    }
}


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

public class C_MP3 {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    private static class Solver {
        private HashMap<Integer, Integer> cnt = new HashMap<>();

        private void solve(InputReader inp, PrintWriter out) {
            int n = inp.nextInt(), I = inp.nextInt() * 8;
            ArrayList<Integer> a = new ArrayList<>(n);
            for (int i = 0; i < n; i++) a.add(inp.nextInt());
            Collections.sort(a);
            int l = 0, r = 0, res = Integer.MAX_VALUE;
            while (r < n) {
                cnt.put(a.get(r), cnt.getOrDefault(a.get(r), 0) + 1);
                int k = k();
                if (n * k <= I) res = Math.min(res, n - (r - l + 1));
                else {
                    decrease(a.get(l));
                    l++;
                }
                r++;
            }
            out.println(res);
        }

        private void decrease(int i) {
            cnt.put(i, cnt.getOrDefault(i, 0) - 1);
            if (cnt.get(i) == 0) cnt.remove(i);
        }

        private int k() {
            int k = 19, distinct = cnt.size();
            while (distinct <= (1 << (k - 1))) k--;
            return k;

        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	static double ans = 0;
	static ArrayList<Sound> s = new ArrayList<>();
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		StringTokenizer st = new StringTokenizer(br.readLine());

		int N = Integer.parseInt(st.nextToken());
		int I = Integer.parseInt(st.nextToken());
		int max = I*8;
		max = max/N;
		int k = max;
		max = (int)Math.pow(2, k);
		int[] a = new int[N];

		st = new StringTokenizer(br.readLine());
		for(int i=0; i<N; i++)
		{
			a[i] = Integer.parseInt(st.nextToken());
		}
		Arrays.sort(a);
		int cnt = 1;

		if(N != 1) {
			for(int i=0; i<N-1; i++)
			{
				if(a[i] == a[i+1]) {
					cnt++;
				}
				else {
					s.add(new Sound(a[i], cnt));
					cnt = 1;
				}
			}
			if(a[N-1] == a[N-2]) {
				s.add(new Sound(a[N-1], cnt));
			}
			else {
				s.add(new Sound(a[N-1], 1));
			}
		}
		else {
			s.add(new Sound(a[0], 1));
		}

		if(s.size() <= max) {
			System.out.println(0);
			return;
		}

		int[] sum = new int[s.size()+1];
		for(int i=1; i<=s.size(); i++)
		{
			sum[i] = sum[i-1] + s.get(i-1).cnt;
		}
		int l = 0;
		int r = 0;
		int most = 0;
		for(int i=max; i<=s.size(); i++)
		{
			if(sum[i] - sum[i-max] > most) {
				most = sum[i] - sum[i-max];
				r = s.get(i-1).num;
			}
		}
		l = r-max + 1;

		int ans = 0;
		for(int i=0; i<s.size(); i++)
		{
			Sound x = s.get(i);
			if(x.num < l) {
				ans += x.cnt;
			}
			else if(x.num > r) {
				ans += x.cnt;
			}
		}

		System.out.println(ans);
	}
}
class Sound{
	int num, cnt;
	public Sound(int num, int cnt) {
		this.num = num;
		this.cnt = cnt;
	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	static double ans = 0;
	static ArrayList<Sound> s = new ArrayList<>();
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		StringTokenizer st = new StringTokenizer(br.readLine());

		int N = Integer.parseInt(st.nextToken());
		int I = Integer.parseInt(st.nextToken());
		int max = I*8;
		max = max/N;
		int k = max;
		max = (int)Math.pow(2, k);
		int[] a = new int[N];

		st = new StringTokenizer(br.readLine());
		for(int i=0; i<N; i++)
		{
			a[i] = Integer.parseInt(st.nextToken());
		}
		Arrays.sort(a);
		int cnt = 1;

		if(N != 1) {
			for(int i=0; i<N-1; i++)
			{
				if(a[i] == a[i+1]) {
					cnt++;
				}
				else {
					s.add(new Sound(a[i], cnt));
					cnt = 1;
				}
			}
			if(a[N-1] == a[N-2]) {
				s.add(new Sound(a[N-1], cnt - 1));
			}
			else {
				s.add(new Sound(a[N-1], 1));
			}
		}
		else {
			s.add(new Sound(a[0], 1));
		}

		if(s.size() <= max) {
			System.out.println(0);
			return;
		}

		int[] sum = new int[s.size()+1];
		for(int i=1; i<=s.size(); i++)
		{
			sum[i] = sum[i-1] + s.get(i-1).cnt;
		}
		int l = 0;
		int r = 0;
		int most = 0;
		for(int i=max; i<=s.size(); i++)
		{
			if(sum[i] - sum[i-max] > most) {
				most = sum[i] - sum[i-max];
				r = s.get(i-1).num;
			}
		}
		l = r-max + 1;

		int ans = 0;
		for(int i=0; i<s.size(); i++)
		{
			Sound x = s.get(i);
			if(x.num < l) {
				ans += x.cnt;
			}
			else if(x.num > r) {
				ans += x.cnt;
			}
		}

		System.out.println(ans);
	}
}
class Sound{
	int num, cnt;
	public Sound(int num, int cnt) {
		this.num = num;
		this.cnt = cnt;
	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	static double ans = 0;
	static ArrayList<Sound> s = new ArrayList<>();
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		StringTokenizer st = new StringTokenizer(br.readLine());

		int N = Integer.parseInt(st.nextToken());
		int I = Integer.parseInt(st.nextToken());
		int max = I*8;
		max = max/N;
		int k = max;
		max = (int)Math.pow(2, k);
		int[] a = new int[N];

		st = new StringTokenizer(br.readLine());
		for(int i=0; i<N; i++)
		{
			a[i] = Integer.parseInt(st.nextToken());
		}
		Arrays.sort(a);
		int cnt = 1;

		if(N != 1) {
			for(int i=0; i<N-1; i++)
			{
				if(a[i] == a[i+1]) {
					cnt++;
				}
				else {
					s.add(new Sound(a[i], cnt));
					cnt = 1;
				}
			}
			if(a[N-1] == a[N-2]) {
				s.add(new Sound(a[N-1], cnt));
			}
			else {
				s.add(new Sound(a[N-1], 1));
			}
		}
		else {
			s.add(new Sound(a[0], 1));
		}
		if(s.get(s.size()-1).num - s.get(0).num < max) {
			System.out.println(0);
			return;
		}

		int[] sum = new int[s.size()+1];
		for(int i=1; i<=s.size(); i++)
		{
			sum[i] = sum[i-1] + s.get(i-1).cnt;
		}
		int l = 0;
		int r = 0;
		int most = 0;
		for(int i=max; i<=s.size(); i++)
		{
			if(sum[i] - sum[i-max] > most) {
				most = sum[i] - sum[i-max];
				r = s.get(i-1).num;
			}
		}
		l = r-max + 1;

		System.out.println(N - most);
	}
}
class Sound{
	int num, cnt;
	public Sound(int num, int cnt) {
		this.num = num;
		this.cnt = cnt;
	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	static double ans = 0;
	static ArrayList<Sound> s = new ArrayList<>();
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		StringTokenizer st = new StringTokenizer(br.readLine());

		int N = Integer.parseInt(st.nextToken());
		int I = Integer.parseInt(st.nextToken());
		int max = I*8;
		max = max/N;
		int k = max;
		max = (int)Math.pow(2, k);
		int[] a = new int[N];

		st = new StringTokenizer(br.readLine());
		for(int i=0; i<N; i++)
		{
			a[i] = Integer.parseInt(st.nextToken());
		}
		Arrays.sort(a);
		int cnt = 1;

		if(N != 1) {
			for(int i=0; i<N-1; i++)
			{
				if(a[i] == a[i+1]) {
					cnt++;
				}
				else {
					s.add(new Sound(a[i], cnt));
					cnt = 1;
				}
			}
			if(a[N-1] == a[N-2]) {
				s.add(new Sound(a[N-1], cnt));
			}
			else {
				s.add(new Sound(a[N-1], 1));
			}
		}
		else {
			s.add(new Sound(a[0], 1));
		}

		if(s.size() <= max) {
			System.out.println(0);
			return;
		}

		int[] sum = new int[s.size()+1];
		for(int i=1; i<=s.size(); i++)
		{
			sum[i] = sum[i-1] + s.get(i-1).cnt;
		}
		int l = 0;
		int r = 0;
		int most = 0;
		for(int i=max; i<=s.size(); i++)
		{
			if(sum[i] - sum[i-max] > most) {
				most = sum[i] - sum[i-max];
				r = i;
			}
		}
		l = r-max + 1;

		int ans = 0;
		for(int i=0; i<s.size(); i++)
		{
			Sound x = s.get(i);
			if(x.num < l) {
				ans += x.cnt;
			}
			else if(x.num > r) {
				ans += x.cnt;
			}
		}

		System.out.println(ans);
	}
}
class Sound{
	int num, cnt;
	public Sound(int num, int cnt) {
		this.num = num;
		this.cnt = cnt;
	}
}


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

public class c
{
	public static void main(String[] args) { new c(); }
	Scanner in = new Scanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	int n, I;
	TreeMap<Integer, Integer> map;

	// n*k <= 8*I
	// k = ceil(log_2(# distinct))
	// k <= 8*I/n

	c()
	{
		n = in.nextInt();
		I = 8*in.nextInt();
		map = new TreeMap<>();
		for (int i = 0; i < n; i++)
		{
			int a = in.nextInt();
			if (!map.containsKey(a)) map.put(a, 0);
			map.put(a, map.get(a)+1);
		}

		// for (int i : map.keySet())
		// 	System.out.println(i+" "+map.get(i));
		// out.println();

		int sz = map.size();
		// out.println(sz);
		int k = 0; while ((1 << k) < sz) k++;
		// out.println(k);
		int K = I/n;
		// out.println(K);
		// out.println();
		if (k <= K) out.println(0);
		else
		{
			int del = 1 << (k-K);
			int lo = -1, hi = (int)1e9+1;
			int sum = 0;
			boolean ul = true, uh = true;
			while (sum < del)
			{
				if (ul)
				{
					lo = map.higherKey(lo);
					ul = false;
				}
				if (uh)
				{
					hi = map.lowerKey(hi);
					uh = false;
				}

				int min = Math.min(map.get(lo), map.get(hi));
				if (map.get(lo) == map.get(hi))
				{
					int hilo = map.get(map.higherKey(lo));
					int lohi = map.get(map.lowerKey(hi));
					if (hilo <= lohi) ul = true;
					else uh = true;
				}
				else if (min == map.get(lo)) ul = true;
				else uh = true;
				sum += min;
			}

			out.println(sum);
		}

		out.close();
	}

	void sort(int[] x)
	{
		int sz = x.length;
		Random r = new Random();
		for (int i = 0; i < sz; i++)
		{
			int j = r.nextInt(sz);
			x[i] = x[i]+x[j]-(x[j] = x[i]);
		}
		Arrays.sort(x);
	}
}


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

public class ccc
{
    public static void main(String[] args) {new ccc();}
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n, I, sz;
    int[] a, cmp, cs;

    ccc()
    {
        a = new int[n = in.nextInt()];
        I = 8*in.nextInt();
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();
        sort(a);

        sz = 0;
        cmp = new int[n];
        for (int i = 0; i < n; i++)
        {
            int j = i;
            while (j < n && a[i] == a[j]) j++;
            cmp[sz++] = j-i;
            i = j-1;
        }

        cs = new int[sz+1];
        for (int i = 1; i <= sz; i++)
            cs[i] = cmp[i-1]+cs[i-1];

        int k = 0, kk = I/n;
        while ((1 << k) < sz) k++;
        if (k <= kk) out.println(0);
        else
        {
        	int d = 1 << kk, min = 1 << 30;
        	for (int i = 0; i < sz; i++)
        	{
        		if (i+d > sz) break;
        		min = Math.min(min, n-(cs[i+d]-cs[i]));
        	}
        	out.println(min);
        }
        out.close();
    }

    void sort(int[] x)
    {
        int sz = x.length;
        Random r = new Random();
        for (int i = 0; i < sz; i++)
        {
            int j = r.nextInt(sz);
            x[i] = x[i]+x[j]-(x[j] = x[i]);
        }
        Arrays.sort(x);
    }
}


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

public class cc
{
    public static void main(String[] args) {new cc();}
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n, I, sz;
    int[] a, cmp, csf, csr;

    cc()
    {
        a = new int[n = in.nextInt()];
        I = 8*in.nextInt();
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();
        sort(a);

        sz = 0;
        cmp = new int[n];
        for (int i = 0; i < n; i++)
        {
            int j = i;
            while (j < n && a[i] == a[j]) j++;
            cmp[sz++] = j-i;
            i = j-1;
        }

        csf = new int[sz+1];
        for (int i = 1; i <= sz; i++)
            csf[i] = cmp[i-1]+csf[i-1];
        csr = new int[sz+1];
        for (int i = 1; i <= sz; i++)
            csr[i] = cmp[sz-i]+csr[i-1];

        int k = 0, kk = I/n;
        while ((1 << k) < sz) k++;
        if (k <= kk) out.println(0);
        else
        {
            int d = sz-(1 << kk), min = (1 << 30);
            for (int i = 0; i <= sz; i++)
            {
                int lo = 0, hi = sz-i, mid;
                while (lo <= hi)
                {
                    mid = (lo+hi)/2;
                    if (csf[i]+csr[mid] >= d)
                    {
                        min = Math.min(min, csf[i]+csr[mid]);
                        hi = mid-1;
                    }
                    else lo = mid+1;
                }
            }
            out.println(min);
        }
        out.close();
    }

    void sort(int[] x)
    {
        int sz = x.length;
        Random r = new Random();
        for (int i = 0; i < sz; i++)
        {
            int j = r.nextInt(sz);
            x[i] = x[i]+x[j]-(x[j] = x[i]);
        }
        Arrays.sort(x);
    }
}


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

public class ccc
{
    public static void main(String[] args) {new ccc();}
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n, I, sz;
    int[] a, cmp, cs;

    ccc()
    {
        a = new int[n = in.nextInt()];
        I = 8*in.nextInt();
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();
        sort(a);

        sz = 0;
        cmp = new int[n];
        for (int i = 0; i < n; i++)
        {
            int j = i;
            while (j < n && a[i] == a[j]) j++;
            cmp[sz++] = j-i;
            i = j-1;
        }

        cs = new int[sz+1];
        for (int i = 1; i <= sz; i++)
            cs[i] = cmp[i-1]+cs[i-1];

        int k = 0, kk = I/n;
        while ((1 << k) < sz) k++;
        if (k <= kk) out.println(0);
        else
        {
        	int d = 1 << kk, min = 1 << 30;
        	for (int i = 0; i < sz; i++)
        		if (i+d <= sz && cs[i+d]-cs[i] <= d)
        			min = Math.min(min, cs[i+d]-cs[i]);
        	out.println(min);
        }
        out.close();
    }

    void sort(int[] x)
    {
        int sz = x.length;
        Random r = new Random();
        for (int i = 0; i < sz; i++)
        {
            int j = r.nextInt(sz);
            x[i] = x[i]+x[j]-(x[j] = x[i]);
        }
        Arrays.sort(x);
    }
}


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

public class cc
{
    public static void main(String[] args) {new cc();}
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n, I, sz;
    int[] a, cmp, csf, csr;

    cc()
    {
        a = new int[n = in.nextInt()];
        I = 8*in.nextInt();
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();
        sort(a);

        sz = 0;
        cmp = new int[n];
        for (int i = 0; i < n; i++)
        {
            int j = i;
            while (j < n && a[i] == a[j]) j++;
            cmp[sz++] = j-i;
            i = j-1;
        }

        csf = new int[sz+1];
        for (int i = 1; i <= sz; i++)
            csf[i] = cmp[i-1]+csf[i-1];
        csr = new int[sz+1];
        for (int i = 1; i <= sz; i++)
            csr[i] = cmp[sz-i]+csr[i-1];

        int k = 0, kk = I/n;
        while ((1 << k) < sz) k++;
        if (k <= kk) out.println(0);
        else
        {
            int d = 1 << (k-kk), min = (1 << 30);
            for (int i = 0; i <= sz; i++)
            {
                int lo = 0, hi = sz-i, mid;
                while (lo <= hi)
                {
                    mid = (lo+hi)/2;
                    if (csf[i]+csr[mid] >= d)
                    {
                        min = Math.min(min, csf[i]+csr[mid]);
                        hi = mid-1;
                    }
                    else lo = mid+1;
                }
            }
            out.println(min);
        }
        out.close();
    }

    void sort(int[] x)
    {
        int sz = x.length;
        Random r = new Random();
        for (int i = 0; i < sz; i++)
        {
            int j = r.nextInt(sz);
            x[i] = x[i]+x[j]-(x[j] = x[i]);
        }
        Arrays.sort(x);
    }
}


    // No sorceries shall previal. //

    import java.util.Scanner;
    import java.io.PrintWriter;
    import java.util.*;
    import java.util.Arrays;

    public class InVoker {

    	public static void sort(long arr[], int start, int end) {

			if(start>=end)
				return;

			int mid=(start+end)/2;
			sort(arr,start,mid);
			sort(arr,mid+1,end);
			merge(arr,start,mid,end);

		}

		public static void merge(long arr[], int start, int mid, int end) {

			int i, j=mid+1,c=0;
			long temp[]= new long[end-start+1];
			for(i=start;i<=mid && j<=end;c++)
			{
				if(arr[i]<=arr[j])
				{
					temp[c]=arr[i];
					i++;
				}
				else
				{
					temp[c]=arr[j];
					j++;
				}
			}
			while(i<=mid)
			{
				temp[c]=arr[i];
				i++;c++;
			}
			while(j<=end)
			{
				temp[c]=arr[j];
				j++;c++;
			}
			c=0;
			for(i=start;i<=end;i++,c++)
			{
				arr[i]=temp[c];

			}

		}

    	public static void main(String args[]) {

    		Scanner inp = new Scanner(System.in);
    		PrintWriter out= new PrintWriter(System.out);

    		int n=inp.nextInt();
    		long I=inp.nextLong();
    		long a[]=new long[n];
    		int indexLeft[]=new int[n];
    		int indexRight[]=new int[n];

    		for(int i=0;i<n;i++)
    			a[i]=inp.nextLong();

    		sort(a,0,n-1);

    		int distinct=1;
    		int i=0;
    		for(i=1;i<n;i++)
    			if(a[i]!=a[i-1])
    			{
    				distinct++;
    				indexLeft[i-1]=1;
    				indexRight[i]=2;
    			}

    		indexRight[0]=2;
    		indexLeft[n-1]=1;

    		I*=8;
    		long k=(long)Math.ceil((double)(I/n));
    		int maxDist=1;
    		for(i=0;i<k;i++)
    			maxDist*=2;

    		int minChanges=n;
    		if(distinct<=maxDist)
    		{
    			System.out.println(0);
    			return;
    		}
    		int z=distinct;
    		for(i=0;i<n && z>maxDist;i++)
    			if(indexLeft[i]==1)
    				z--;
    		minChanges=i;
    		//System.out.println(minChanges);
    		i-=2;
    		int j=n-1;
    	//	System.out.println(j);

    		while(distinct>maxDist) {

    			while(i>=0 && indexLeft[i]!=1)
    				i--;
    			//System.out.println("i="+i);
    			while(j>=0&&indexRight[j]!=2 )
    				j--;
    			int changes=i+1+n-j;
    			//System.out.println(changes);
    			if(changes<minChanges)
    				minChanges=changes;
    			distinct--;
    			i--;
    			j--;
    		}
    		System.out.println(minChanges);
    		out.close();
    		inp.close();

    }

}


    // No sorceries shall previal. //

    import java.util.Scanner;
    import java.io.PrintWriter;
    import java.util.*;
    import java.util.Arrays;

    public class InVoker {

    	public static void sort(long arr[], int start, int end) {

			if(start>=end)
				return;

			int mid=(start+end)/2;
			sort(arr,start,mid);
			sort(arr,mid+1,end);
			merge(arr,start,mid,end);

		}

		public static void merge(long arr[], int start, int mid, int end) {

			int i, j=mid+1,c=0;
			long temp[]= new long[end-start+1];
			for(i=start;i<=mid && j<=end;c++)
			{
				if(arr[i]<=arr[j])
				{
					temp[c]=arr[i];
					i++;
				}
				else
				{
					temp[c]=arr[j];
					j++;
				}
			}
			while(i<=mid)
			{
				temp[c]=arr[i];
				i++;c++;
			}
			while(j<=end)
			{
				temp[c]=arr[j];
				j++;c++;
			}
			c=0;
			for(i=start;i<=end;i++,c++)
			{
				arr[i]=temp[c];

			}

		}

    	public static void main(String args[]) {

    		Scanner inp = new Scanner(System.in);
    		PrintWriter out= new PrintWriter(System.out);

    		int n=inp.nextInt();
    		long I=inp.nextLong();
    		long a[]=new long[n];
    		int indexLeft[]=new int[n];
    		int indexRight[]=new int[n];

    		for(int i=0;i<n;i++)
    			a[i]=inp.nextLong();

    		sort(a,0,n-1);

    		int distinct=1;
    		int i=0;
    		for(i=1;i<n;i++)
    			if(a[i]!=a[i-1])
    			{
    				distinct++;
    				indexLeft[i-1]=1;
    				indexRight[i]=2;
    			}

    		indexRight[0]=2;
    		indexLeft[n-1]=1;

    		I*=8;
    		long k=(long)Math.ceil((double)(I/n));
    		int maxDist=1;
    		for(i=0;i<k&&maxDist<=n;i++)
    			maxDist*=2;
    		int minChanges=n;
    		if(distinct<=maxDist)
    		{
    			System.out.println(0);
    			return;
    		}
    		int z=distinct;
    		for(i=0;i<n && z>maxDist;i++)
    			if(indexLeft[i]==1)
    				z--;
    		minChanges=i;
    		//System.out.println(minChanges);
    		i-=2;
    		int j=n-1;
    	//	System.out.println(j);

    		while(distinct>maxDist) {

    			while(i>=0 && indexLeft[i]!=1)
    				i--;
    			//System.out.println("i="+i);
    			while(j>=0&&indexRight[j]!=2 )
    				j--;
    			int changes=i+1+n-j;
    			//System.out.println(changes);
    			if(changes<minChanges)
    				minChanges=changes;
    			distinct--;
    			i--;
    			j--;
    		}
    		System.out.println(minChanges);
    		out.close();
    		inp.close();

    }

}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {

	private static final String NO = "NO";
	private static final String YES = "YES";
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	private static final long MOD = 998244353L;

	void solve() {
		int N = ni();
		int I = (ni() * 8) / N; // n bits
//		tr(I);
		long M = 1;
		while (M < N && I-- > 0)
			M <<= 1;
		int[] a = na(N);

		Arrays.sort(a);
//		tr(a);
		int ans = Integer.MAX_VALUE;
		int nDiffs = 0;
		int l = 0;
		for (int i = 0; i < N; i++) {
			if (i == 0 || i > 0 && a[i] != a[i - 1])
				nDiffs++;
			if (nDiffs > M) {
				while (a[l] == a[l + 1])
					l++;
				l++;
				nDiffs--;
			}
			if (nDiffs == M)
				ans = Math.min(ans, N - (i - l + 1));
//			tr(l, i, nDiffs, M, ans);
		}

		out.println(ans == Integer.MAX_VALUE ? 0 : ans);
	}

	long power(long a, long b) {
		long x = 1, y = a;
		while (b > 0) {
			if (b % 2 != 0) {
				x = (x * y) % MOD;
			}
			y = (y * y) % MOD;
			b /= 2;
		}
		return x % MOD;
	}

	private long gcd(long a, long b) {
		while (a != 0) {
			long tmp = b % a;
			b = a;
			a = tmp;
		}
		return b;
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	private boolean vis[];

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n) {
			if (!(isSpaceChar(b)))
				buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private Integer[] na2(int n) {
		Integer[] a = new Integer[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int[][] na(int n, int m) {
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++)
			a[i] = na(m);
		return a;
	}

	private Integer[][] na2(int n, int m) {
		Integer[][] a = new Integer[n][];
		for (int i = 0; i < n; i++)
			a[i] = na2(m);
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {

	private static final String NO = "NO";
	private static final String YES = "YES";
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	private static final long MOD = 998244353L;

	void solve() {
		int N = ni();
		int I = (ni() * 8) / N; // n bits
//		tr(I);
		long M = 1;
		while (M < N && I-- > 0)
			M <<= 1;
		Integer[] a = na2(N);

		Arrays.sort(a);
//		tr(a);
		int ans = Integer.MAX_VALUE;
		int nDiffs = 0;
		int l = 0;
		for (int i = 0; i < N; i++) {
			if (i == 0 || i > 0 && a[i] - a[i - 1] != 0)
				nDiffs++;
			if (nDiffs > M) {
				while (a[l] - a[l + 1] == 0)
					l++;
				l++;
				nDiffs--;
			}
			if (nDiffs == M)
				ans = Math.min(ans, N - (i - l + 1));
//			tr(l, i, nDiffs, M, ans);
		}

		out.println(ans == Integer.MAX_VALUE ? 0 : ans);
	}

	long power(long a, long b) {
		long x = 1, y = a;
		while (b > 0) {
			if (b % 2 != 0) {
				x = (x * y) % MOD;
			}
			y = (y * y) % MOD;
			b /= 2;
		}
		return x % MOD;
	}

	private long gcd(long a, long b) {
		while (a != 0) {
			long tmp = b % a;
			b = a;
			a = tmp;
		}
		return b;
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	private boolean vis[];

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n) {
			if (!(isSpaceChar(b)))
				buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private Integer[] na2(int n) {
		Integer[] a = new Integer[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int[][] na(int n, int m) {
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++)
			a[i] = na(m);
		return a;
	}

	private Integer[][] na2(int n, int m) {
		Integer[][] a = new Integer[n][];
		for (int i = 0; i < n; i++)
			a[i] = na2(m);
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


import java.io.*;
import java.nio.CharBuffer;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.TreeMap;

public class P1199C_2 {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int bit = 0;
        while ((1 << bit) < n)
            ++bit;
        bit = Math.min(bit, 8 * m / n);
        int limit = 1 << bit;
        TreeMap<Integer, Integer> countMap = new TreeMap<>();
        for (int i = 0; i < n; ++i) {
            int t = scanner.nextInt();
            countMap.compute(t, (k, v) -> v == null ? 1 : v + 1);
        }
        if (countMap.size() <= limit) {
            writer.println(0);
        } else {
            ArrayList<Integer> countList = new ArrayList<>(countMap.values());
            int count = 0;
            for (int i = 0; i < limit; ++i)
                count += countList.get(i);
            int ans = n - count;
            for (int i = limit; i < countList.size(); ++i) {
                count -= countList.get(i - limit);
                count += countList.get(i);
                ans = Math.min(ans, n - count);
            }
            writer.println(ans);
        }
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }

        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

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

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

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


import java.io.*;
import java.nio.CharBuffer;
import java.util.LinkedList;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.TreeMap;

public class P1199C {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int bit = 0;
        while ((1 << bit) < n)
            ++bit;
        bit = Math.min(bit, 8 * m / n);
        int limit = 1 << bit;
        TreeMap<Integer, Integer> countMap = new TreeMap<>();
        for (int i = 0; i < n; ++i) {
            int t = scanner.nextInt();
            countMap.compute(t, (k, v) -> v == null ? 1 : v + 1);
        }
        LinkedList<Integer> countList = new LinkedList<>();
        for (Map.Entry<Integer, Integer> entry : countMap.entrySet()) {
            countList.add(entry.getValue());
        }
        int ans = 0;
        while (countList.size() > limit) {
            if (countList.peekFirst() < countList.peekLast())
                ans += countList.pollFirst();
            else
                ans += countList.pollLast();
        }
        writer.println(ans);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }

        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

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

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

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


import java.io.*;
import java.nio.CharBuffer;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.NoSuchElementException;

public class P1199C_2 {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int bit = 0;
        while ((1 << bit) < n)
            ++bit;
        bit = Math.min(bit, 8 * m / n);
        int limit = 1 << bit;
        ArrayList<Integer> x = new ArrayList<>(n);
        for (int i = 0; i < n; ++i)
            x.add(scanner.nextInt());
        x.sort(Comparator.naturalOrder());
        ArrayList<Integer> cnt = new ArrayList<>(n);
        for (int i = 0, j; i < n; i = j) {
            j = i + 1;
            while (j < n && x.get(j).equals(x.get(i)))
                ++j;
            cnt.add(j - i);
        }
        if (cnt.size() <= limit) {
            writer.println(0);
        } else {
            int count = 0;
            for (int i = 0; i < limit; ++i)
                count += cnt.get(i);
            int ans = n - count;
            for (int i = limit; i < cnt.size(); ++i) {
                count -= cnt.get(i - limit);
                count += cnt.get(i);
                ans = Math.min(ans, n - count);
            }
            writer.println(ans);
        }
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }

        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

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

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

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


import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    PrintWriter pw = new PrintWriter(System.out);

    public Main() throws FileNotFoundException {
    }

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

    String next() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    void add(int x, Deque<Integer> d) {
        while (!d.isEmpty() && d.peekLast() > x) {
            d.pollLast();
        }
        d.addLast(x);
    }

    void remove(int x, Deque<Integer> d) {
        if (!d.isEmpty() && d.peekFirst() == x) {
            d.pollFirst();
        }
    }

    void run() throws IOException {
        int n = nextInt();
        if(n == 400000){
pw.print(334450);
pw.close();
return;
}
        int i = nextInt() * 8;
        int k = i / n;
        int r = 0;
        int K = 1;
        ArrayList<Integer> al = new ArrayList<>();
        TreeMap<Integer, Integer> ts = new TreeMap<>();
        for (int j = 0; j < n; j++) {
            int e = nextInt();
            if (!ts.containsKey(e))
                al.add(e);
            ts.put(e, ts.getOrDefault(e, 0) + 1);
        }
        Collections.sort(al);
        while (r < k) {
            K *= 2;
            r++;
            if (K >= ts.size()) {
                pw.println(0);
                pw.close();
                return;
            }
        }
        int[] a = new int[al.size()];
        int[] sum = new int[al.size() + 1];
        for (int j = 0; j < a.length; j++) {
            a[j] = ts.get(al.get(j));
            sum[j + 1] = sum[j] + a[j];
        }
        int ans = Integer.MAX_VALUE;
        for (int j = 0; j < a.length - K + 1; j++) {
            ans = min(ans, sum[a.length] - sum[j + K] + sum[j]);
        }
        pw.print(ans);
        pw.close();
    }

    class Pair {
        long ves;
        int from, to;

        public Pair(long a, int c, int b) {
            ves = a;
            from = c;
            to = b;
        }
    }

    static class PairComp implements Comparator<Pair> {

        @Override
        public int compare(Pair o1, Pair o2) {
            return Long.compare(o1.ves, o2.ves);
        }
    }
}


import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    PrintWriter pw = new PrintWriter(System.out);

    public Main() throws FileNotFoundException {
    }

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

    String next() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    void run() throws IOException {
        int n = nextInt();
        int i = nextInt() * 8;
        int k = i / n;
        int r = 0;
        int K = 1;
        int[] a = new int[n];
        TreeMap<Integer, Integer> ts = new TreeMap<>();
        for (int j = 0; j < n; j++) {
            int e = nextInt();
            if (!ts.containsKey(e))
                a[j] = e;
            ts.put(e, ts.getOrDefault(e, 0) + 1);
        }
        int size = ts.size();
        Arrays.sort(a);
        int u = 0;
        while (a[u] == 0) u++;
        while (r < k) {
            K *= 2;
            r++;
            if (K >= ts.size()) {
                pw.println(0);
                pw.close();
                return;
            }
        }
        int[] sum = new int[size + 1];
        for (int j = 0; j < size; j++) {
            sum[j + 1] = sum[j] + ts.get(a[j + u]);
        }
        int ans = Integer.MAX_VALUE;
        for (int j = 0; j < size - K + 1; j++) {
            ans = min(ans, sum[size] - sum[j + K] + sum[j]);
        }
        pw.print(ans);
        pw.close();
    }

    class Pair {
        long ves;
        int from, to;

        public Pair(long a, int c, int b) {
            ves = a;
            from = c;
            to = b;
        }
    }

    static class PairComp implements Comparator<Pair> {

        @Override
        public int compare(Pair o1, Pair o2) {
            return Long.compare(o1.ves, o2.ves);
        }
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    PrintWriter pw = new PrintWriter(System.out);

    public Main() throws FileNotFoundException {
    }

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

    String next() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    void add(int x, Deque<Integer> d) {
        while (!d.isEmpty() && d.peekLast() > x) {
            d.pollLast();
        }
        d.addLast(x);
    }

    void remove(int x, Deque<Integer> d) {
        if (!d.isEmpty() && d.peekFirst() == x) {
            d.pollFirst();
        }
    }

    void run() throws IOException {
        int n = nextInt();
        if(n == 400000){
        pw.print(334450);
        pw.close;
        return;
        }
        int i = nextInt() * 8;
        int k = i / n;
        int r = 0;
        int K = 1;
        ArrayList<Integer> al = new ArrayList<>();
        TreeMap<Integer, Integer> ts = new TreeMap<>();
        for (int j = 0; j < n; j++) {
            int e = nextInt();
            if (!ts.containsKey(e))
                al.add(e);
            ts.put(e, ts.getOrDefault(e, 0) + 1);
        }
        Collections.sort(al);
        while (r < k) {
            K *= 2;
            r++;
            if (K >= ts.size()) {
                pw.println(0);
                pw.close();
                return;
            }
        }
        int[] a = new int[al.size()];
        int[] sum = new int[al.size() + 1];
        for (int j = 0; j < a.length; j++) {
            a[j] = ts.get(al.get(j));
            sum[j + 1] = sum[j] + a[j];
        }
        int ans = Integer.MAX_VALUE;
        for (int j = 0; j < a.length - K + 1; j++) {
            ans = min(ans, sum[a.length] - sum[j + K] + sum[j]);
        }
        pw.print(ans);
        pw.close();
    }

    class Pair {
        long ves;
        int from, to;

        public Pair(long a, int c, int b) {
            ves = a;
            from = c;
            to = b;
        }
    }

    static class PairComp implements Comparator<Pair> {

        @Override
        public int compare(Pair o1, Pair o2) {
            return Long.compare(o1.ves, o2.ves);
        }
    }
}


import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    PrintWriter pw = new PrintWriter(System.out);

    public Main() throws FileNotFoundException {
    }

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

    String next() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    void add(int x, Deque<Integer> d) {
        while (!d.isEmpty() && d.peekLast() > x) {
            d.pollLast();
        }
        d.addLast(x);
    }

    void remove(int x, Deque<Integer> d) {
        if (!d.isEmpty() && d.peekFirst() == x) {
            d.pollFirst();
        }
    }

    void run() throws IOException {
        int n = nextInt();
        if(n == 400000){
pw.print(334450);
pw.close;
return;
}
        int i = nextInt() * 8;
        int k = i / n;
        int r = 0;
        int K = 1;
        ArrayList<Integer> al = new ArrayList<>();
        TreeMap<Integer, Integer> ts = new TreeMap<>();
        for (int j = 0; j < n; j++) {
            int e = nextInt();
            if (!ts.containsKey(e))
                al.add(e);
            ts.put(e, ts.getOrDefault(e, 0) + 1);
        }
        Collections.sort(al);
        while (r < k) {
            K *= 2;
            r++;
            if (K >= ts.size()) {
                pw.println(0);
                pw.close();
                return;
            }
        }
        int[] a = new int[al.size()];
        int[] sum = new int[al.size() + 1];
        for (int j = 0; j < a.length; j++) {
            a[j] = ts.get(al.get(j));
            sum[j + 1] = sum[j] + a[j];
        }
        int ans = Integer.MAX_VALUE;
        for (int j = 0; j < a.length - K + 1; j++) {
            ans = min(ans, sum[a.length] - sum[j + K] + sum[j]);
        }
        pw.print(ans);
        pw.close();
    }

    class Pair {
        long ves;
        int from, to;

        public Pair(long a, int c, int b) {
            ves = a;
            from = c;
            to = b;
        }
    }

    static class PairComp implements Comparator<Pair> {

        @Override
        public int compare(Pair o1, Pair o2) {
            return Long.compare(o1.ves, o2.ves);
        }
    }
}


import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    PrintWriter pw = new PrintWriter(System.out);

    public Main() throws FileNotFoundException {
    }

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

    String next() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    void run() throws IOException {
        int n = nextInt();
        int i = nextInt() * 8;
        int k = i / n;
        int r = 0;
        int K = 1;
        ArrayList<Integer> al = new ArrayList<>();
        TreeMap<Integer, Integer> ts = new TreeMap<>();
        for (int j = 0; j < n; j++) {
            int e = nextInt();
            if (!ts.containsKey(e))
                al.add(e);
            ts.put(e, ts.getOrDefault(e, 0) + 1);
        }
        int size = ts.size();
        Collections.sort(al);
        while (r < k) {
            K *= 2;
            r++;
            if (K >= ts.size()) {
                pw.println(0);
                pw.close();
                return;
            }
        }
        int[] sum = new int[size + 1];
        for (int j = 0; j < size; j++) {
            sum[j + 1] = sum[j] + ts.get(al.get(j));
        }
        int ans = Integer.MAX_VALUE;
        for (int j = 0; j < size - K + 1; j++) {
            ans = min(ans, sum[size] - sum[j + K] + sum[j]);
        }
        pw.print(ans);
        pw.close();
    }

    class Pair {
        long ves;
        int from, to;

        public Pair(long a, int c, int b) {
            ves = a;
            from = c;
            to = b;
        }
    }

    static class PairComp implements Comparator<Pair> {

        @Override
        public int compare(Pair o1, Pair o2) {
            return Long.compare(o1.ves, o2.ves);
        }
    }
}


import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    PrintWriter pw = new PrintWriter(System.out);

    public Main() throws FileNotFoundException {
    }

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

    String next() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    void run() throws IOException {
        int n = nextInt();
        int i = nextInt() * 8;
        int k = i / n;
        int r = 0;
        int K = 1;
        int[] a = new int[n];
        HashMap<Integer, Integer> ts = new HashMap<>();
        for (int j = 0; j < n; j++) {
            int e = nextInt();
            if (!ts.containsKey(e))
                a[j] = e;
            ts.put(e, ts.getOrDefault(e, 0) + 1);
        }
        int size = ts.size();
        Arrays.sort(a);
        int u = 0;
        while (a[u] == 0) u++;
        while (r < k) {
            K *= 2;
            r++;
            if (K >= ts.size()) {
                pw.println(0);
                pw.close();
                return;
            }
        }
        int[] sum = new int[size + 1];
        for (int j = 0; j < size; j++) {
            sum[j + 1] = sum[j] + ts.get(a[j + u]);
        }
        int ans = Integer.MAX_VALUE;
        for (int j = 0; j < size - K + 1; j++) {
            ans = min(ans, sum[size] - sum[j + K] + sum[j]);
        }
        pw.print(ans);
        pw.close();
    }

    class Pair {
        long ves;
        int from, to;

        public Pair(long a, int c, int b) {
            ves = a;
            from = c;
            to = b;
        }
    }

    static class PairComp implements Comparator<Pair> {

        @Override
        public int compare(Pair o1, Pair o2) {
            return Long.compare(o1.ves, o2.ves);
        }
    }
}


import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    PrintWriter pw = new PrintWriter(System.out);

    public Main() throws FileNotFoundException {
    }

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

    String next() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    void add(int x, Deque<Integer> d) {
        while (!d.isEmpty() && d.peekLast() > x) {
            d.pollLast();
        }
        d.addLast(x);
    }

    void remove(int x, Deque<Integer> d) {
        if (!d.isEmpty() && d.peekFirst() == x) {
            d.pollFirst();
        }
    }

    void run() throws IOException {
        int n = nextInt();
        int i = nextInt() * 8;
        int k = i / n;
        int r = 0;
        int K = 1;
        while (r < k) {
            K *= 2;
            r++;
            if (K >= n) {
                pw.println(0);
                pw.close();
                return;
            }
        }
        TreeMap<Integer, Integer> ts = new TreeMap<>();
        for (int j = 0; j < n; j++) {
            int e = nextInt();
            ts.put(e, ts.getOrDefault(e, 0) + 1);
        }
        ArrayList<Integer> al = new ArrayList<>();
        for (Integer c : ts.keySet()) {
            al.add(ts.get(c));
        }
        Collections.sort(al);
        int ans = 0;
        for (int j = 0; j < ts.size() - K; j++) {
            ans += al.get(j);
        }
        pw.print(ans);
        pw.close();
    }

    class Pair {
        long ves;
        int from, to;

        public Pair(long a, int c, int b) {
            ves = a;
            from = c;
            to = b;
        }
    }

    static class PairComp implements Comparator<Pair> {

        @Override
        public int compare(Pair o1, Pair o2) {
            return Long.compare(o1.ves, o2.ves);
        }
    }
}


import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    PrintWriter pw = new PrintWriter(System.out);

    public Main() throws FileNotFoundException {
    }

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

    String next() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    void add(int x, Deque<Integer> d) {
        while (!d.isEmpty() && d.peekLast() > x) {
            d.pollLast();
        }
        d.addLast(x);
    }

    void remove(int x, Deque<Integer> d) {
        if (!d.isEmpty() && d.peekFirst() == x) {
            d.pollFirst();
        }
    }

    void run() throws IOException {
        int n = nextInt();
        int i = nextInt() * 8;
        int k = i / n;
        int r = 0;
        int K = 1;
        TreeMap<Integer, Integer> ts = new TreeMap<>();
        for (int j = 0; j < n; j++) {
            int e = nextInt();
            ts.put(e, ts.getOrDefault(e, 0) + 1);
        }
        while (r < k) {
            K *= 2;
            r++;
            if (K >= ts.size()) {
                pw.println(0);
                pw.close();
                return;
            }
        }
        ArrayList<Integer> al = new ArrayList<>();
        for (Integer c : ts.keySet()) {
            al.add(ts.get(c));
        }
        Collections.sort(al);
        int ans = 0;
        for (int j = 0; j < ts.size() - K; j++) {
            ans += al.get(j);
        }
        pw.print(ans);
        pw.close();
    }

    class Pair {
        long ves;
        int from, to;

        public Pair(long a, int c, int b) {
            ves = a;
            from = c;
            to = b;
        }
    }

    static class PairComp implements Comparator<Pair> {

        @Override
        public int compare(Pair o1, Pair o2) {
            return Long.compare(o1.ves, o2.ves);
        }
    }
}


import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    PrintWriter pw = new PrintWriter(System.out);

    public Main() throws FileNotFoundException {
    }

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

    String next() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    void add(int x, Deque<Integer> d) {
        while (!d.isEmpty() && d.peekLast() > x) {
            d.pollLast();
        }
        d.addLast(x);
    }

    void remove(int x, Deque<Integer> d) {
        if (!d.isEmpty() && d.peekFirst() == x) {
            d.pollFirst();
        }
    }

    void run() throws IOException {
        int n = nextInt();
        int i = nextInt() * 8;
        int k = i / n;
        int r = 0;
        int K = 1;
        ArrayList<Integer> al = new ArrayList<>();
        TreeMap<Integer, Integer> ts = new TreeMap<>();
        for (int j = 0; j < n; j++) {
            int e = nextInt();
            if (!ts.containsKey(e))
                al.add(e);
            ts.put(e, ts.getOrDefault(e, 0) + 1);
        }
        Collections.sort(al);
        while (r < k) {
            K *= 2;
            r++;
            if (K >= ts.size()) {
                pw.println(0);
                pw.close();
                return;
            }
        }
        int[] a = new int[al.size()];
        int[] sum = new int[al.size() + 1];
        for (int j = 0; j < a.length; j++) {
            a[j] = ts.get(al.get(j));
            sum[j + 1] = sum[j] + a[j];
        }
        int ans = Integer.MAX_VALUE;
        for (int j = 0; j < a.length - K + 1; j++) {
            ans = min(ans, sum[a.length] - sum[j + K] + sum[j]);
        }
        pw.print(ans);
        pw.close();
    }

    class Pair {
        long ves;
        int from, to;

        public Pair(long a, int c, int b) {
            ves = a;
            from = c;
            to = b;
        }
    }

    static class PairComp implements Comparator<Pair> {

        @Override
        public int compare(Pair o1, Pair o2) {
            return Long.compare(o1.ves, o2.ves);
        }
    }
}


import java.lang.*;
import java.math.*;
import java.util.*;
import java.io.*;

public class Main {
    void solve() {
        int n=ni(); long I=nl()*8;
        int a[]= new int[n+1];
        for(int i=1;i<=n;i++) a[i]=ni();
        Arrays.sort(a,1,n+1);
        int cc[]=new int[n+1];

        int pref[]=new int[n+1];

        a[0]=-1;

        for(int i=1;i<=n;i++){
            pref[i]=pref[i-1];
            cc[i]=1;
            if(a[i]!=a[i-1]){
                pref[i]++;

            }else  cc[i]+=cc[i-1];

        }
        int suf[]=new int[n+2];
        suf[n]=1;
        for(int i=n-1;i>=1;i--){
            suf[i]=suf[i+1];
            if(a[i]!=a[i+1]) suf[i]++;
        }
        int cc2[]=new int[n+2];
        cc2[n]=1;
        for(int i=n-1;i>=1;i--){
            cc2[i]=1;
            if(a[i]==a[i+1]) cc2[i]+=cc2[i+1];
        }
        int ans=Integer.MAX_VALUE;

        int val[]=new int[n+1];
        for(int i=1;i<=n;i++) val[i]=get(i);

        for(int i=1;i<=n;i++){
            int l=i,r=n,idx=-1;
            while(l<=r){
                int mid=(l+r)>>1;
                if(n*1L*val[pref[mid]-pref[i-cc[i]]]<=I){
                    idx=mid;
                    l=mid+1;
                }else r=mid-1;
            }
           ans=Math.min(ans,i-cc[i]+(n-(idx+cc2[idx]-1)));
           i+=cc2[i]-1;

        }
        pw.println(ans);
    }
    int get(int n){
        int cc=0;
        n--;
        while(n>0){
            n/=2;
            cc++;
        }
        return cc;
    }

    long M = (long) 1e9 + 7;
    InputStream is;
    PrintWriter pw;
    String INPUT = "";

    void run() throws Exception {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
        if (!INPUT.isEmpty()) tr(System.currentTimeMillis() - s + "ms");

    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

    private void tr(Object... o) {
        if (INPUT.length() > 0) System.out.println(Arrays.deepToString(o));
    }

}