#include<iostream>
#include<unordered_set>
using namespace std;
typedef long long ll;
const int N = 50;
int a[N];
int n;
int num;
int ans;
bool st[N];
unordered_set<ll> q;
bool judge(ll x) {
bool n = true;
for (int i = 2; i*i < x; i++)
if (x % i == 0) {
n = false;
break;
}
return n;
}
void dfs(ll step, ll sum) {
if (step == num) {
if (judge(sum) && !q.count(sum))
ans++, q.insert(sum);
return;
}
for (int i = 1; i <= n; i++) {
if (!st[i]) {
st[i] = true;
dfs(step + 1, sum + a[i]);
st[i] = false;
}
}
}
int main() {
cin >> n >> num;
for (int i = 1; i <= n; i++)
cin >> a[i];
dfs(0, 0);
cout << ans;
return 0;
}