#include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template constexpr T INF = ::numeric_limits::max() / 32 * 15 + 208; #include class xor_shift { uint32_t x, y, z, w; public: xor_shift() : x(static_cast((chrono::system_clock::now().time_since_epoch().count())&((1LL << 32)-1))), y(1068246329), z(321908594), w(1234567890) {}; uint32_t urand(){ uint32_t t; t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); return w; }; int rand(int n){ if(n < 0) return -rand(-n); uint32_t t = numeric_limits::max()/(n+1)*(n+1); uint32_t e = urand(); while(e >= t) e = urand(); return static_cast(e%(n+1)); } int rand(int a, int b){ if(a > b) swap(a, b); return a+rand(b-a); } }; template< class T> T pow_ (T x, uint64_t n, uint64_t M){ T u = 1; if(n > 0){ u = pow_(x, n/2, M); if (n % 2 == 0) u = (u*u) % M; else u = (((u * u)% M) * x) % M; } return u; }; bool suspect(__uint128_t a, uint64_t s, uint64_t d, uint64_t n){ __uint128_t x = pow_(a, d, n); if (x == 1) return true; for (int r = 0; r < s; ++r) { if(x == n-1) return true; x = x * x % n; } return false; } template bool miller_rabin(T m){ uint64_t n = m; if (n <= 1 || (n > 2 && n % 2 == 0)) return false; uint64_t d = n - 1, s = 0; while (!(d&1)) {++s; d >>= 1;} vector v = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; if(n <= 4759123141LL) v = {2, 7, 61}; for (auto &&p : v) { if(p >= n) break; if(!suspect(p, s, d, n)) return false; } return true; } int main() { int n, k; cin >> n >> k; vector v(n); for (auto &&i : v) scanf("%d", &i); xor_shift rd; ll st = 1e15; auto m = rd.rand(st, st*5); while(!miller_rabin(m)) m = rd.rand(st, st*5); set s; for (int i = 0; i < (1 << n); ++i) { if(__builtin_popcount(i) < k) continue; ll x = 1, y = 0; for (int j = 0; j < n; ++j) { if(i & (1 << j)){ (x *= v[j]) %= m; y += v[j]; } } s.emplace(x); s.emplace(y); } cout << s.size() << "\n"; return 0; }