#include <iostream>
#include <vector>
using namespace std;
int n,k;
const int N = 30;
int a[N];
int path,cnt;
bool isprime(int x)
{if(x<=1) return false;else{for(int i = 2;i<x;i++){if(x%i == 0)return false;}return true;}
}
void dfs(int pos,int begin)
{if(pos>k){if(isprime(path))cnt++;return;}for(int i = begin;i<=n;i++){path+=a[i];dfs(pos+1,i+1);path-=a[i];}
}
int main()
{cin >> n >> k;for(int i = 1;i<=n;i++){cin >> a[i];}dfs(1,1);cout << cnt << endl;return 0;
}