using System.Collections.Generic; using System.Linq; using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var k = int.Parse(line[1]); line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); getAn(n, k, a); } static void getAn(int n, int k, int[] a) { var hs = new HashSet(); var imax = 1 << n; for (int i = 0; i < imax; i++) { if (countbit(i) >= k) { var s1 = 0; var s2 = 1L; for (int j = 0; j < n; j++) { if (((i >> j) & 1) == 1) { s1 += a[j]; s2 *= a[j]; } } hs.Add(s1); hs.Add(s2); } } Console.WriteLine(hs.Count()); } static int countbit(long bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (int)(bits & 0x0000ffff) + (int)(bits >> 16 & 0x0000ffff); } }