#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std ;
const int N = 1e7 ;
int st[N] , a[N] , b[N] , sum ;
int n , k ;
//判断素数
bool fun(int n)
{
if (n == 1)
return false;
if (n == 2)
return true;
for (int i = 2; i <= sqrt(n); i += 2)
{
if (n % i == 0)
return false;
}
return true;
}
void dfs( int u , int start )
{
if( u > k)
{
int x = 0 ;
for( int i = 1 ; i <= k ; i++)
{
// cout << b[i] << ' ';
x += b[i] ;
}
// cout << endl ;
if( fun(x) )
{
sum++ ;
}
return ;
}
for( int i = start ; i <= n ; i++)
{
if( st[i] == 0)
{
b[u] = a[i] ;
st[i] = 1 ;
dfs(u + 1 , i + 1) ;
st[i] = 0 ;
}
}
}
int main()
{
cin >> n >> k ;
for( int i = 1 ; i <= n ; i++)
{
cin >> a[i] ;
}
sort( a + 1 , a + n) ;
dfs(1 , 1) ;
cout << sum << endl ;
}