#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 25;
int n, k;
int s;
int ans;
int a[N];
bool used[N];
bool check(int x){
if(x == 0 || x == 1) return false;
for(int i = 2; i * i <= x; i++)
if(x % i == 0) return false;
return true;
}
void dfs(int u, int start){
if(u > k){
if(check(s)) ans++;
return;
}
for(int i = start; i <= n; i++){
if(!used[i]){
used[i] = true;
s += a[i];
dfs(u + 1, start + 1);
s -= a[i];
used[i] = false;
}
}
}
int main(){
cin >> n >> k;
for(int i = 1; i <= n; i++)
cin >> a[i];
dfs(1, 1);
cout << ans << endl;
return 0;
}