fun main(args:Array<String>):Unit {
    while(true){
        val n = readLine()!!.trim().toInt()
        val k = readLine()!!.trim().toInt()
        if (n == 0 && k == 0) return
        val canMake = mutableSetOf<Int>()
        val cards = Array(n){readLine()!!.trim().toInt()}.toIntArray()
        setCanMake(k, cards, canMake)
        println(canMake.size)
    }
}
fun setCanMake(k:Int, cards:IntArray, canMake:MutableSet<Int>, made:Int = 0, used:Int = 0){
    if (k == 0){
        canMake.add(made)
        return
    }
    for (i in cards.indices){
        if (used and (1 shl i) == 0){
            setCanMake(k - 1, cards, canMake, cards[i] + made * if (cards[i] >= 10) 100 else 10, used or (1 shl i))
        }
    }
}
