loop do
  n, k = [gets, gets].map(&:to_i)

  break if n == 0 and k == 0

  cards = []

  ans = []

  n.times{ cards.push(gets.to_i) }

  cards.permutation(k) {|*a| ans.push(a.join) } 

  puts ans.uniq.length
end