#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n, k;
	while (1){
		cin >> n >> k;
		if (n == 0 and k == 0) return 0;
		string s[n];
		set<string> s_perm;;
		for (int i = 0; i < n; i++) cin >> s[i];

		sort(s, s+n);

		do {
			string tmp;
			for (int i = 0; i < k; i++) tmp += s[i];
			s_perm.insert(tmp);
		} while (next_permutation(s, s+n));

		cout << (int)s_perm.size() << endl;
	}
}

