/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

int n, m;
int ans;
int x[15];
//map<LL, int>mp;

void dfs(int pos, LL num){
	if(pos == m + 1){
		ans++;
		return ;
	}
	for (int i = 1; i <= n; i++){
		if(x[i]){
			x[i]--;
			dfs(pos + 1, num * 10 + i);
			x[i]++;
		}
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);


	while(scanf("%d %d", &n, &m) == 2){
		//mp.clear();
		ans = 0;
		int sum = 0;
		for (int i = 1; i <= n; i++){
			scanf("%d", &x[i]);
			sum += x[i];
		}
		if(sum < m){
			printf("0\n");
			continue;
		}
		dfs(1, 0);
		printf("%d\n", ans);
	}

	return 0;
}
/**/