loop do
  n = gets.to_i
  k = gets.to_i
  break if (n|k)==0
  cs = Array.new
  n.times{
    cs << gets.chomp
  }
  ns = Array.new
  cs.permutation(k).to_a.each{|ary|
    ns << ary.join
  }
  puts ns.uniq.size
end