import util.control.Breaks._

object Main extends App {
  breakable {
    while (true) {
      val n = io.StdIn.readInt()
      val k = io.StdIn.readInt()
      if (n == 0 && k == 0) break()
      val an = Array.fill(n)(io.StdIn.readLine())
      val results = collection.mutable.Set.empty[String]
      for (c <- an.combinations(k))
        for (p <- c.permutations) {
          results += p.mkString("")
        }
      println(results.size)
    }
  }
}
