#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[30];
bool f[30];
int cnt;
bool check(int x)
{
if(x < 2)
{
return 0;
}
for(int i = 2;i * i <= x;i++)
{
if(x % i == 0)
{
return 0;
}
}
return 1;
}
void dfs(int s)
{
if(s == k)
{
int sum = 0;
for(int i = 1;i <= 20;i++)
{
if(f[i])
{
sum += a[i];
}
}
cnt += check(sum);
}
for(int i = 1;i <= n - (k - s + 1) + 1;i++)
{
// 求这一段怎么写
// f[i] = 1;
// dfs(s + 1);
// f[i] = 0;
}
}
int main()
{
cin >> n >> k;
for(int i = 1;i <= n;i++)
{
cin >> a[i];
}
dfs(1);
cout << cnt;
}