n, k = map(int, input().split()) a = list(map(int, input().split())) t = set() for s in range(1 << n): if bin(s).count('1') < k: continue x = 0 y = 1 for d in range(n): if s >> d & 1: x += a[d] y *= a[d] t.add(x) t.add(y) print(len(t))