require "set" N, K = gets.split.map(&:to_i) A = gets.split.map(&:to_i) set = Set.new (1 << N).times do |bits| sum = 0 prod = 1 count = 0 N.times do |i| next if bits[i] == 0 sum += A[i] prod *= A[i] count += 1 end next if count < K set << sum << prod end puts set.size