object Main extends App {
  import scala.io.StdIn._
  val Array(n, r) = readLine.trim.split(' ').map(_.toInt)
  val numbers = readLine.trim.split(' ').map(_.toInt - 1)
  val uft = new UnionFind(n + 1)
  for (i ← numbers.indices) {
    uft.merge(i, numbers(i))
  }
  var size = Nil: List[Int]
  for (i ← numbers.indices if !uft.isSame(i, n)) {
    size ::= uft.sizeOf(i)
    uft.merge(i, n)
  }
  val values = size.groupBy(identity).mapValues(_.length).toArray.sortBy(_._1)
  val memo = Array.fill(math.min(n - r, r) + 1){false}
  memo(0) = true
  for ((v, c) ← values) {
    var i = 0
    while ((1 << (i + 1)) <= c) {
      val value = v << i
      for (j ← (0 until memo.length - value).reverse if memo(j)) {
        memo(j + value) = true
      }
      i += 1
    }
    val rest = c - (1 << i) + 1
    val value = rest * v
    if (rest != 0) for (j ← (0 until memo.length - value).reverse if memo(j)) {
      memo(j + value) = true
    }
  }
  println(
    if (memo.last) "Yes" else "No"
  )
}
class UnionFind(val size: Int) {
  private[this] val parent = Array.fill(size){-1}
  def find(a: Int): Int = {
    if (parent(a) < 0) a
    else {
      parent(a) = find(parent(a))
      parent(a)
    }
  }
  def isSame(a: Int, b: Int): Boolean = find(a) == find(b)
  def merge(a: Int, b: Int): Unit = {
    val ar = find(a)
    val br = find(b)
    if (ar != br){
      if (parent(ar) < parent(br)) {
        parent(ar) += parent(br)
        parent(br) = ar
      }else {
        parent(br) += parent(ar)
        parent(ar) = br
      }
    }
  }
  def sizeOf(a: Int): Int = -parent(find(a))
}
