N,K = map(int,input().split()) A = list(map(int,input().split())) ans = set() def popcnt(x): res = 0 while x: res += (x & 1) x >>= 1 return res for s in range(1 << N): if popcnt(s) < K: continue plus = 0 mul = 1 for i in range(N): if (s >> i) & 1: plus += A[i] mul *= A[i] ans.add(plus) ans.add(mul) print(len(ans))