n, k = map(int, input().split()) a = list(map(int, input().split())) num_set = set() for i in range(1 << k - 1, 1 << n): if bin(i).count("1") < k: continue s = 0 p = 1 for j in range(n): if i >> j & 1: s += a[j] p *= a[j] num_set.add(s) num_set.add(p) print(len(num_set))