import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  val tweet = Array.tabulate(n){_ ⇒ readLine.trim.toInt}
  val resCount = Array.tabulate(n){_ ⇒ 0}
  for (t ← tweet if t != 0){
    resCount(t - 1) += 1
  }
  val queue:mutable.Queue[Int] = mutable.Queue()
  for (i ← resCount.indices if resCount(i) == 0){
    queue.enqueue(i)
  }
  for (_ ← 1 to k){
    for (_ ← queue.indices){
      val i = queue.dequeue()
      if (tweet(i) != 0){
        queue.enqueue(tweet(i) - 1)
        tweet(i) = 0
      }
    }
  }
  println(
    tweet.count(_ == 0)
  )


  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
