jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()

########################################################################################################################################################################

show_flg=False
show_flg=True

ans=0

a,b,c=LI()
k=I()
q=0
for i in range(k+1):
    for j in range(k-i+1):
        #show(c*2**i,b*2**j,a*2**(k-i-j),(i,j,k-i-j),c*2**i>b*2**j>a*2**(k-i-j))
        if c*2**i>b*2**j>a*2**(k-i-j):
            q=1

Yn(q)
//  [java]
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();

		for ( int i=0; i<k; i++ ) {
			if ( a>=b )  b *= 2;
			else if ( b>=c )  c *= 2;
		}

		if ( a<b && b<c ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}
//  [java]
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
    	Scanner scanner = new Scanner(System.in);
      
      	int red = scanner.nextInt();
      	int green = scanner.nextInt();
      	int blue = scanner.nextInt();
      	int count = scanner.nextInt();
            
        while(!((blue > green) && (green > red))) {
        	if(blue > green) {
              green *= 2;
            } else {
              blue *= 2;
            }
          
          	count -= 1;
        }
      
      	if(count >= 0) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");        
        }
    
    }
}
//  [java]
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();

        for(int i = 0; i < k; i++){
            if(a < b){
                if(b < c){
                    System.out.println("Yes");
                    return;
                }else{
                    c *= 2;
                }
            }else{
                b *= 2;
            }
            if(a < b && b < c){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");

    }
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,m;
string s;
vll f;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	while(a >= b && k) b*=2,k--;
	while(b >= c && k) c*=2,k--;
	if(a<b && b<c) cout<<"Yes\n";
	else cout<<"No\n"; 
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(T--) {
		MAIN();
	}
	return 0;
}
//  [cpp]
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
    
ll K;
bool yes=false; 

bool judge (ll a, ll b, ll c, ll count) {
  cerr << a <<" "<< b <<" "<< c <<" "<< count << endl;
  if (count > K) {
    return false;
  }
  if(b > a && c > b) {
    yes = true;
    return true;
  } 
  judge (a*2, b, c, count+1);
  judge (a, b*2, c, count+1);
  judge (a, b, c*2, count+1);
  return false;
}
int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  cin >> K;

  judge (A, B, C, 0);
  if(yes) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
//  [c]
#include <stdio.h>

int main() {
  int A, B, C, K;
  int diff, i;
  
  scanf("%d %d %d\n", &A, &B, &C);
  scanf("%d\n", &K);
  
  while((K >= 0) && (A >= B)) {
    B *= 2;
    K--;
  }
  
  while((K >= 0) && (B >= C)) {
    C *= 2;
    K--;
  }
  
  printf("%s\n", (K >= 0) ? "Yes" : "No");
  
  return 0;
}
//  [c]
int main() {
	int a, b, c;
	int k;
	scanf("%d" "%d" "%d", &a, &b, &c);
	scanf("%d", &k);
	for (int i = 0; i < k; i++) {
		if (a >= c) {
			c *= 2;
			continue;
		}
		if (a >= b) {
			b *= 2;
			continue;
		}
		if (b >= c) {
			c *= 2;
			continue;
		}
	}
	if (a < b && b < c)
		printf("Yes");
	else printf("No");
	
	
	return 0;
}
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {

    input = input.split("\n");
  
    let vals = input[0].split(" ");
    
    let A = parseInt(vals[0], 10);  // 赤
    let B = parseInt(vals[1], 10);  // 緑
    let C = parseInt(vals[2], 10);  // 青

    let cnt = parseInt(input[1], 10);

    let i = 0;

    while (A >= B) {
        B = B * 2;
        i++;
    }

    while (B >= C) {
        C = C * 2;
        i++;
    }

    if (i <= cnt) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(lines) {
  let [a, b, c] = splitN(lines[0]);
  const K = +lines[1];

  for (let i = 0; i < K; i++) {
    if (a >= b) b *= 2;
    else if (b >= c) c *= 2;
  }
  
  return a < b && b < c ? 'Yes' : 'No';
}


const ans = main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );
console.log( ans );

function splitN(s) {
  return s.split(' ').map(Number);
}
//  [javascript]
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var A = one[0];
	var B = one[1];
	var C = one[2];
	var K = nextInt();
	var output = "No";
	dfs(one, 0);
	myout(output);
	function dfs(list, count){
		if(list[0] < list[1] && list[1] < list[2]){
			output = "Yes";
			return;
		}
		if(count == K){
			return;
		}
		var tmp = makeClone(list);
		tmp[0] *= 2;
		dfs(tmp, count + 1);
		var tmp = makeClone(list);
		tmp[1] *= 2;
		dfs(tmp, count + 1);
		var tmp = makeClone(list);
		tmp[2] *= 2;
		dfs(tmp, count + 1);
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	A, B, C := getStdinInt3()
	K := getStdinInt()

	AOri := A
	BOri := B
	COri := C

	for a := 0; a <= K; a++ {
		for b := 0; b <= K; b++ {
			for c := 0; c <= K; c++ {
				if a+b+c != K {
					continue
				}
				A = AOri
				B = BOri
				C = COri
				for n := 0; n < a; n++ {
					A = A * 2
				}
				for n := 0; n < b; n++ {
					B = B * 2
				}
				for n := 0; n < c; n++ {
					C = C * 2
				}
				if A < B && B < C {
					fmt.Printf("Yes\n")
					return
				}
			}
		}
	}
	fmt.Printf("No\n")
	return
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
//  [ruby]
require 'pp'

r, g, b = gets.split.map(&:to_i)
k = gets.to_i

k.times do |i|
    if r >= g
        g *= 2
    elsif g >= b
        b *= 2
    end

    #print b, g, r
    #puts ""
end

if b > g && g > r
    puts "Yes"
else
    puts "No"
end
//  [ruby]
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
a,b,c = gets.chomp.split.map(&:to_i)
k = gets.chomp.to_i

k.times do |i|
  if a >= b
    b *= 2
  elsif b >= c
    c *= 2
  end
end

if a<b && b < c
  puts 'Yes'
else
  puts 'No'
end
//  [ruby]
a,b,c = gets.split(" ").map(&:to_i)
n = gets.to_i

result = "No"
for i in 0..n
  for j in 0..(n-i)
    k = n - i -j
    x = a * (2 ** i)
    y = b * (2 ** j)
    z = c * (2 ** k)
    if y > x && z > y
      result = "Yes"
      break
    end
  end
end

puts result
//  [rust]
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let a: usize = sc.read();
    let b: usize = sc.read();
    let c: usize = sc.read();
    let k: usize = sc.read();

    let mut ans = false;
    for i in 0..=k {
        for j in 0..=(k - i) {
            if b * 2_usize.pow(j as u32) > a * 2_usize.pow(i as u32)
                && c * 2_usize.pow(k as u32 - i as u32 - j as u32) > b * 2_usize.pow(j as u32)
            {
                ans = true;
            }
        }
    }

    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}
//  [swift]

import Foundation

let a = readLine()!.components(separatedBy: " ").map{ Int($0)! }
var R = a[0]
var G = a[1]
var B = a[2]
let K = Int(readLine()!)!

for i in 1...K {
    if B > G && G > R {
        print("Yes")
        break
    } else if G <= R {
        G *= 2
        if B > G && G > R {
            print("Yes")
            break
        }
    } else if B <= G {
        B *= 2
        if B > G && G > R {
            print("Yes")
            break
        }
    }
    if i == K {
        print("No")
    }
    
}
//  [swift]
import Foundation

precedencegroup PowerPrecedence {
    higherThan: MultiplicationPrecedence
}
infix operator ^^: PowerPrecedence
func ^^(radix: Int, power: Int) -> Int {
    Int(pow(Double(radix), Double(power)))
}

let abc = readLine()!
    .split(separator: " ")
    .map { Int($0)! }
let a = abc[0]
let b = abc[1]
let c = abc[2]
let limit = Int(readLine()!)!
var result = false

LOOP:
for i in 0..<limit {
    for j in i..<limit {
        let r = a * 2 ^^ i
        let g = b * 2 ^^ (j - i)
        let b = c * 2 ^^ (limit - j)
        if b > g && g > r {
            result = true
            break LOOP
        }
    }
}

print(result ? "Yes" : "No")
//  [python]
import collections
n,k = map(int,input().split())
a = input().split()
a = list(collections.Counter(a).values())
a.sort(reverse = True)
a = sum(a[:k])
if a == n:
  print(0)
else:
  print(n-a)
//  [python]
import collections

n, k = map(int,input().split())
a = input().split()
a = sorted(collections.Counter(a).values(), reverse=True)
s = sum(a[:k])

print(0 if s == n else n - s)
//  [python]
import collections
n,k = map(int,input().split())
a = input().split()
a = sorted(list(collections.Counter(a).values()))
print(sum(a[:len(a)-k]))
//  [python]
import numpy as np

N, K = map(int, input().split())

A = list(map(int, input().split()))
A.sort()
key = A[0]

B = []
cnt = 1

for i in range(1,N):
    if key == A[i]:
        cnt += 1
    else:
        key = A[i]
        B.append(cnt)
        cnt = 1

B.append(cnt)

B.sort(reverse=True)

print(sum(B[K:]))
//  [python]
import numpy as np
st=input().split()
N=int(st[0]);K=int(st[1])
S=set([])
st=input().split()
P=[0]*(N+1)
Q=[0]*(N+1)
for i in range(N):
    k=int(st[i])
    S.add(k)
    P[k-1]+=1
    Q[P[k-1]-1]-=1
    Q[P[k-1]]+=1
out=0
change=0
count=0
if len(S)<=K:
    print(0)
else:
    for i in range(1,N+1):
        flag=1
        for j in range(Q[i]):
            change+=i
            count+=1
            if count==max([len(S)-K,0]):
                flag=0
                break
        if flag==0:
            break
    print(change)
//  [python]
n, k = map(int, input().split())
a = list(map(int, input().split()))

d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

if len(d.keys()) <= k:
    print(0)
else:
    a = list(d.values())
    b = sorted(d.values())[-k:]
    for i in b:
        if i in a:
            a.remove(i)
    print(sum(a))
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = sc.nextInt();

		int[] count = new int[200000];
		for (int i = 0; i < N; i++)
			count[A[i] - 1]++;
		int ans = 0;
		Arrays.sort(count);
		for (int i = 0; i < 200000 - K; i++)
			ans += count[i];

		System.out.println(ans);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}
//  [java]
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt(), k=fsc.nextInt();
        int[] cnt=new int[200000];
        for(int i=0;i<n;i++){
            int a=fsc.nextInt()-1;
            cnt[a]++;
        }
        fsc.close();
        revSort(cnt);
        int sum=0;
        for(int i=0;i<k;i++){
            sum+=cnt[i];
        }
        System.out.println(n-sum);
    }
    static void revSort(int[] a){
        Arrays.sort(a);
        int l=a.length;
        int tmp;
        for(int i=0;i<l/2;i++){
            tmp=a[i];
            a[i]=a[l-i-1];
            a[l-i-1]=tmp;
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int s[] = new int[n+1];

		for(int i = 0; i < n; i++) {
			int val = Integer.parseInt(sc.next());
			s[val]++;
		}
		Arrays.sort(s);

		int ans = 0;
		int cnt = 0;
		for(int i = n; i > 0; i--) {
			ans += s[i];
			cnt++;

			if(cnt == k)
				break;
		}
		System.out.println(n - ans);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

}
//  [java]
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] n_k = sc.nextLine().split(" ");
		int k = Integer.parseInt(n_k[1]);
		Map<Integer,Integer> balls = Arrays.asList(sc.nextLine().split(" "))
				.parallelStream()
				.map(Integer::valueOf)
				.collect(Collectors.toMap(i->i,j->1,(s,a)->s+a));
		List<Integer> count=balls
				.values()
				.parallelStream()
				.sorted()
				.collect(Collectors.toList());
		int nowK=balls.size(),result=0;
		for(Integer i:count) {
			if(nowK--<=k)break;
			result+=i;
		}
		System.out.println(result);
	}
}
//  [java]
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeSet;

class ball implements Comparable<ball>{
	int num, id;
	public ball(int n, int i) {
		num = n; id = i;
	}
	public int compareTo(ball o) {
		if(num == o.num) return id - o.id;
		return num - o.num;
	}
}
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), K = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for(int i = 0; i < N; i++) {
			int A = sc.nextInt();
			if(map.containsKey(A)) map.put(A, map.get(A) + 1);
			else map.put(A, 1);
		}
		/* 本質 */
		int ans = 0;
		TreeSet<ball> balls = new TreeSet<ball>();
		for(Entry<Integer, Integer> e : map.entrySet()) {
			balls.add(new ball(e.getValue(), e.getKey()));
		}
		while(balls.size() > K) {
			ans += balls.pollFirst().num;
		}
		System.out.println(ans);
	}
}
//  [java]
import java.util.Comparator;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), k = scanner.nextInt();
        System.out.println(IntStream.range(0, n)
                .boxed()
                .collect(Collectors.groupingBy(i -> scanner.nextInt(), Collectors.reducing(0, i -> 1, Integer::sum)))
                .values().stream()
                .sorted(Comparator.reverseOrder())
                .skip(k)
                .mapToInt(Integer::intValue)
                .sum());
    }
}
//  [cpp]
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

char in[1<<21];
char const*o;

inline void init_in() { 
  o = in;
  in[fread(in,1,sizeof(in)-4,stdin)] = 0;
}

int readInt(){ 
  unsigned u = 0, s = 0;
  while(*o && *o <= 32){
    ++o;
  }
   
  while(*o>='0' && *o<='9'){
    u = (u<<3) + (u << 1) + (*o++ - '0');
  }

  return static_cast<int>((u^s)) ;
}

int cnt[202020];
template<typename T> void fastout(T &n) {
  T N = n, rev, count = 0;
  rev = N;
  if (N == 0) {
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}
int main(){
  init_in();
  int n = readInt(); int k = readInt();
  
  for (int i = 0; i < n; ++i) {
    int x = readInt();
    ++cnt[x];
  }
  
  sort(cnt, cnt + n + 1 , greater<int>());

  n -= accumulate(cnt, cnt + k, int());

  fastout(n);

  return 0;
}
//  [cpp]
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<queue>
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;
typedef double lf;
typedef unsigned un;
typedef int in;
#define mian main
#define maxn 10000+10
#define maxm 10000+10
#define _(a) read(a)
#define non void
#define inf 2147483647
#define bre break
#define con continue
#define prq priority_queue
#define re register
#define bu bool
#define cz char
#define cst const
#define ope operator
#define inl inline
#define upp upper_bound
#define low lower_bound
#define next_per next_permutation
inl cz gc(){static cz buf[100000],*L=buf,*R=buf;return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;}
template<typename T>inl T Max(T a,T b){return a>b?a:b;}
template<typename T>inl T Min(T a,T b){return a<b?a:b;}
template<typename T>inl T Abs(T a){return a<0?-a:a;}
template<typename T>inl non read(T &a){a=0;T k=1;char c=gc();while(c<'0'||c>'9')k=c=='-'?-1:k,c=gc();while(c>='0'&&c<='9')a=a*10+(c^48),c=gc();if(c!='.'){a*=k;return;}T t=0.1;while(c<'0'||c>'9')c=gc();while(c>='0'&&c<='9')a+=t*(c^48),c=gc(),t*=0.1;a*=k;}
template<typename T>non write(T a,cz t=' '){if(a==0){putc(48,stdout),putc(t,stdout);return;}if(a<0){a=-a;putc('-',stdout);}cz c[30];in le=0;while(a){c[++le]=a%10+48;a/=10;}for(re in i=le;i>=1;--i)putc(c[i],stdout);putc(t,stdout);}
in n,k,a,s,m[300000];
in main()
{
	read(n),read(k);
	for(re in i=1;i<=n;++i){read(a);++m[a];}
	sort(m+1,m+1+n);
	for(in i=n;i>n-k;--i)s+=m[i];
	write(n-s);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
}
//  [cpp]
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

char in[1<<21];
char const*o;

inline void init_in() { 
  o = in;
  in[fread(in,1,sizeof(in)-4,stdin)] = 0;
}

int readInt(){ 
  unsigned u = 0, s = 0;
  while(*o && *o <= 32){
    ++o;
  }
  if (*o == '-'){
    s = ~s, ++o;
  } else if (*o == '+'){
    ++o;
  }
   
  while(*o>='0' && *o<='9'){
    u = (u<<3) + (u << 1) + (*o++ - '0');
  }

  return static_cast<int>((u^s) + !!s) ;
}

int cnt[202020];
template<typename T> void fastout(T &n) {
  T N = n, rev, count = 0;
  rev = N;
  if (N == 0) {
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}
int main(){
  init_in();
  int n = readInt(); int k = readInt();
  
  for (int i = n - 1; i >= 0; --i) {
    int x = readInt();
    ++cnt[x];
  }
  
  sort(cnt, cnt + n + 1 , greater<int>());

  n -= accumulate(cnt, cnt + k, int());

  fastout(n);

  return 0;
}
//  [cpp]
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0; i<n;i++)

int main()
{
    int n,k,tmp,type=0,max=0;
    int a[200002]={0};
    int overflow;
    
    cin >> n >> k;
    REP(i,n)
    {
        cin >> tmp;
        a[tmp-1]++;
    }
    
    REP(i,n)
    {
        if(a[i]>0)
        {
            type++;
            if(max < a[i])
            {
                max = a[i];
            }
        }
    }
    if(type <= k)
    {
        cout << "0" << endl;
    }
    else
    {
        overflow = type - k;
        int count = 0;
        REP(j,max)
        {
            REP(i,200000)
            {
                if(a[i] == j+1)
                {
                    count += j+1;
                    overflow--;
                }
                if(overflow == 0)
                {
                    j=i=20000099;
                }
            }
        }
        cout << count << endl;
    }

    return 0;
}
//  [cpp]
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(x) cout << x << endl
const int INF = 1e+8+7;
ll n,m;
int a,b,c = 0;
string s,t;
// int d[100],dp1[500][500],dp2[500][500];
int d[200010];
vi vec;

int main(){
  cin >> n >> m;
  rep(i,0,n){
    cin >> a;
    d[a]++;
  }
  lep(i,1,n){
    if(d[i] != 0)c++;
  }
  if(c <= m){
    b = 0;
  }else{
    int count = 0;
    lep(i,1,n){
      lep(j,1,n){
        if(d[j] == i){
          count++;
          b += i;
          d[j] = -1;
        }
        if(count == c-m)break;
      }
      if(count == c-m)break;
    }
  }
  print(b);
  return 0;
}
//  [cpp]
#include <iostream>
#include <string>
#include <set>
//#include <bits/stdc++.h>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int a[200010];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int b[200010] = { 0 };

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

	int cnt = 0;

	int variety = 0;
	for (int i = 0; i <= n; i++) {
		if (b[i])
			variety++;
	}

	int head = 0;
	int sum = 1;
	
	while (variety > k) {
		for (int i = head; i <= n; i++) {
			if (b[i] == sum) {
				b[i] = 0;
				cnt += sum;
				variety--;
				head = i;
				break;
			}
			if (i == n) {
				sum++;
				head = 0;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>


#define BUF_SIZE 2000000
typedef unsigned char uchar;

int comp(const void* a, const void* b) {
  return *(int*)b - *(int*)a;
}

#define BUCKET_SIZE 200001

int main(void) {
  int num, kind;
  char line[BUF_SIZE];
  FILE* fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  sscanf(line, "%d %d", &num, &kind);

  int i;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmpbuf = line;
  long sz = sysconf(_SC_PAGESIZE);
  long pagesize = sizeof(int)*(num+1)+(sz-1)/sz;
  // void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
  int* hist = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  // int hist[BUCKET_SIZE] = {0};
  for(i = 0; i < num; i++) {
    char* tmp = strtok(tmpbuf, " ");
    int n = strtol(tmp, NULL, 10);
    hist[n]++;
    tmpbuf = NULL;
  }
  qsort(hist, num+1, sizeof(int), comp); //descending order

  int sum = 0;
  for(i = kind; i < num+1 && hist[i] != 0; i++) {
    sum += hist[i];
  }
  printf("%d\n", sum);
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 2000000
typedef unsigned char uchar;

int comp(const void* a, const void* b) {
  return *(int*)b - *(int*)a;
}

#define BUCKET_SIZE 200001

int main(void) {
  int num, kind;
  char line[BUF_SIZE];
  FILE* fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  sscanf(line, "%d %d", &num, &kind);

  int i;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmpbuf = line;
  int hist[BUCKET_SIZE] = {0};
  for(i = 0; i < num; i++) {
    char* tmp = strtok(tmpbuf, " ");
    int n = strtol(tmp, NULL, 10);
    hist[n]++;
    tmpbuf = NULL;
  }
  qsort(hist, BUCKET_SIZE, sizeof(int), comp); //descending order

  int sum = 0;
  for(i = kind; i < BUCKET_SIZE; i++) {
    sum += hist[i];
  }
  printf("%d\n", sum);
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>


#define BUF_SIZE 2000000
typedef unsigned char uchar;

int comp(const void* a, const void* b) {
  return *(int*)b - *(int*)a;
}

#define BUCKET_SIZE 200001

int main(void) {
  int num, kind;
  char line[BUF_SIZE];
  FILE* fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  sscanf(line, "%d %d", &num, &kind);

  int i;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmpbuf = line;
  long sz = sysconf(_SC_PAGESIZE);
  long pagesize = sizeof(int)*(num+1)+(sz-1)/sz;
  int* hist = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
  for(i = 0; i < num; i++) {
    char* tmp = strtok(tmpbuf, " ");
    int n = strtol(tmp, NULL, 10);
    hist[n]++;
    tmpbuf = NULL;
  }
  qsort(hist, num+1, sizeof(int), comp); //descending order

  int sum = 0;
  for(i = kind; i < num+1 && hist[i] != 0; i++) {
    sum += hist[i];
  }
  printf("%d\n", sum);
  return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
int s[200002],zz[200002],hh[200002];

int main()
{
	int z,a,b,i,h,cs,j,p,k;
	scanf("%d %d",&a,&b);
	
		memset(s,0,sizeof(s));
	
		z=0;cs=0;
		for(i=1;i<=a;i++)
		{
		scanf("%d",&h);
		s[h]++;
		
		if(s[h]==1){z++;zz[z]=h;}
		
		}
		
		if(z<=b)cs=0;
		else if(z==a)cs=z-b;
		else 
		{
			
			k=z-b;
			
			for(j=1;j<=z;j++)
			{
				hh[j]=s[zz[j]];
			}
			for(i=1;i<=z;i++)
			for(j=1;j<=z-i;j++)
			{
				if(hh[j]>hh[j+1])
				{
					p=hh[j];hh[j]=hh[j+1];hh[j+1]=p;
				}
			}
			for(i=1;i<=k;i++)cs+=hh[i];
			
		}
		printf("%d\n",cs);
	
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
void quick_sort(int[],int,int);
int partition(int[],int,int);

int main() {
    int n,k,i,d=0,e=0;
    scanf("%d %d ",&n,&k);
    int a[n],b[2000000];
    for(i=0;i<2000000;i++)
        b[i]=0;
    for(i=0;i<n;i++)
    {scanf("%d ",&a[i]);
     b[a[i]-1]++;}
    
    quick_sort(b,0,2000000-1);
    for(i=0;i<2000000;i++)
    {
       if(b[i]!=0)
            d++;
        
        
        
        
    }
    
    if(d>k)
    {
       int j=d-k;
        
        {
            for(i=0;i<2000000;i++)
      if(b[i]!=0 )
        {
          
          e+=b[i];
          j--;
          if(j==0)
              break;
              
          
      }
        }
        printf("%d",e);
    }
    else
        printf("0");
    return 0;
}
void quick_sort(int a[],int l,int u)
{
    int j;
    if(l<u)
    {
        j=partition(a,l,u);
        quick_sort(a,l,j-1);
        quick_sort(a,j+1,u);
    }
}
 
int partition(int a[],int l,int u)
{
    int v,i,j,temp;
    v=a[l];
    i=l;
    j=u+1;
    
    do
    {
        do
            i++;
            
        while(a[i]<v&&i<=u);
        
        do
            j--;
        while(v<a[j]);
        
        if(i<j)
        {
            temp=a[i];
            a[i]=a[j];
            a[j]=temp;
        }
    }while(i<j);
    
    a[l]=a[j];
    a[j]=v;
    
    return(j);
}
//  [javascript]
// https://atcoder.jp/contests/abc081/tasks/arc086_a
"use strict";
function Main(input) {
  const params = input.trim().split("\n");
  const [N, K] = params[0].trim().split(" ").map(Number);
  const A = params[1].trim().split(" ").map(Number);
  const counts = Array(N + 1).fill(0);

  for (let i = 0; i < N; i++) {
    counts[A[i]] = counts[A[i]] + 1;
  }
  const filterdCounts = counts.sort((a, b) => a - b).filter((a) => a);
  if (filterdCounts.length <= K) {
    console.log(0);
    return;
  }

  let rewriteCount = 0;
  let change = filterdCounts.length - K;
  for (let i = 0; i < change; i++) {
    rewriteCount += filterdCounts[i];
  }
  console.log(rewriteCount);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(s) {
  var s = s.split("\n");
  var n = s[0].split(" ")[0] * 1;
  var k = s[0].split(" ")[1] * 1;
  var a = s[1].split(" ");
  var arr = new Array(n).fill(0);
  a.forEach(e => arr[e - 1]++);
  var ans = 0;
  var v = arr.sort((a, b) => a - b);
  for (var i = 0; i < v.length - k; i++) {
    ans += v[i];
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
    
const main = arg => {
  // とりあえず切り分け
  let Nums = arg.split("\n");
  let N = Nums[0].split(" ")[0]*1;
  let K = Nums[0].split(" ")[1]*1;
  let bowls = Nums[1].split(" ");
  // 0埋めした配列
  let bowl_amount = new Array(N).fill(0);
  let ans = 0;
  bowls.forEach(
    (bowl)=>{
      	// 配列の要素に格納するために１つずらして該当するものを見つけるたびに足してく
    	bowl_amount[bowl - 1]++;
    }
  );
  // 小さい順に並べる
  let bowlArr = bowl_amount.sort((a,b)=>{return a-b}).reverse();
  // 該当する要素数の足し合わせ
  for(let i = N-1; i >= K; i--){
  	ans += bowlArr[i];
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
//Object.entries()
function entries(obj) {
    array = [];
    for (var i of Object.keys(obj)) {
        tmp = new Array(i, obj[i]);
        array.push(tmp);
    }
    return array;
}
function Main(input) {
    input = input.split("\n");
    input[0] = input[0].split(" ").map(Number);
    N = input[0][0];
    K = input[0][1];
    A = input[1].split(" ").map(Number);
    obj = {};
    for (i of A) {
        if (!obj[i]) obj[i] = 1;
        else obj[i]++;
    }
    array = entries(obj).sort((a, b) => a[1] - b[1]);
    ans = 0;
    if (array.length > K) for (i = 0; i < array.length - K; i++) ans += array[i][1];
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict"

function main(input) {
  input = input.split(/\n|\s/).map(v => ~~v)
  const k = input[1]
  const nums = input.slice(2, -1).sort((a, b) => a - b)
  let ans = 0

  let items = []
  let pointer = null
  for (let i = 0; i < nums.length; i++) {
    if (
      i == 0 ||
      items[pointer].key == undefined ||
      items[pointer].key != nums[i]
    ) {
      pointer = pointer === null ? 0 : pointer + 1
      items[pointer] = {
        key: nums[i],
        count: 1
      }
    } else {
      items[pointer].count += 1
    }
  }

  // sort by count
  items.sort((a, b) => {
    return a.count - b.count
  })

  const diff = items.length - k
  const tar = items.slice(0, diff)
  for (let i in tar) {
    ans += tar[i].count
  }

  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))
//  [javascript]
'use strict'

const main = (input) => {
    input = input.split('\n')
    const N = parseInt(input[0].split(' ')[0])
    const K = parseInt(input[0].split(' ')[1])
    const arr = input[1].split(' ').map(v => parseInt(v))
    let obj = {}
    for(let i = 0; i < arr.length; i++){
        if(obj[arr[i]] === undefined){
            obj[arr[i]] = 0
        }
        obj[arr[i]]++
    }
    let arr1 = []
    for(let key in obj){
        arr1.push([key, obj[key]])
    }
    arr1.sort((a, b) => a[1] - b[1])
    const arr1Length = arr1.length

    let sum = 0
    for(let i = 0; i < arr1Length - K; i++){
        sum += arr1[i][1]
    }
    console.log(sum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, k := scanInt(), scanInt()
	c := make([]int, n+1)
	for i := 0; i < n; i++ {
		c[scanInt()]++
	}
	sort.Ints(c)

	b := 0
	for i := 0; i < k; i++ {
		b += c[n-i]
	}
	fmt.Fprintln(wr, n-b)

}