#include<iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;
static const int MAX_N = 10;

int main(){
	for(;;){
		int n, k;
		string s[MAX_N];
		set<string> sa;
		cin >> n >> k;
		if(n == 0 && k == 0) break;
		for(int i = 0; i < n; i++) cin >> s[i];
		sort(s, s + n);
		do{
			string t = "";
			for(int i = 0; i < k; i++) t += s[i];
			sa.insert(t);
		}while(next_permutation(s, s + n));
		cout << sa.size() << endl;
	}
	return 0;
}

