object Main extends App {
	
	val NK = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val A = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	var S = new Array[Int](NK(0))
	var ans = 0

	for(i<-A){
		S(i-1) = S(i-1) + 1
	}

	S = S.filter(_ != 0).sorted

	while(S.size > NK(1)){
		ans = ans + S.head
		S = S.tail
	}



	println(ans)


}
