n, k = map(int, input().split()) A = list(map(int, input().split())) se = set() for bit in range(1 << n): if bin(bit).count("1") < k: continue tot = 0 prod = 1 for i in range(n): if bit >> i & 1: tot += A[i] prod *= A[i] se |= {tot, prod} print(len(se))