#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	while(1){
		int n, k;
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) return 0;
		//??°?????????????????¨????????±???
		vector<string> data(n);//??\?????????????????\??????
		set<string> num;//k???????????§??§?????????????????\??????
		rep(i, n) cin >> data[i];
		
		sort(data.begin(), data.end());//?????????????????????
		//next_permutaion??§??¨???????????????
		do{
			string tmp;
			//??????????????????k???????????£?????????
			rep(i, k){
				tmp += data[i];
			}
			//set?????\???????????¨??§??????????????????????????????????????????????????????
			num.insert(tmp);
		}while(next_permutation(data.begin(), data.end()));
		printf("%lu\n", num.size());//?????°?????¨???
	}
}