#include "bits/stdc++.h"

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define all(co) co.begin(), co.end()
using namespace std;
//using P = pair<int, int>;

int main() {
	int n;
	while (cin >> n && n) {
		int k; cin >> k;
		vector<string> vec(n);
		rep(i, n) cin >> vec[i];

		set<string> sets;
		vector<bool> used(n);
		function<void(string, int)> dfs = [&](string str, int count) {
			if (count == k) {
				sets.insert(str);
				return;
			}
			rep(i, n) if (!used[i]) {
				used[i] = true;
				dfs(str + vec[i], count + 1);
				used[i] = false;
			}
		};
		dfs("", 0);
		cout << sets.size() << endl;
	}
	return 0;
}
#include<iostream>
#include<vector>
#include<set>
#include<string>

using namespace std;

int n,m;
vector<int> came;
string str[11];
set<string> ans;

void serch(int loop,string sans)
{
//	cout << "loop:" << loop << endl;
	if(loop==m)
	{
//		cout << "came:" ;
//		for(int i=0;i<came.size();i++)
//			cout <<  came[i] << " " ;
//		cout << endl;
//		cout << sans << endl;;
		ans.insert(sans);
		return ;
	}
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<came.size();j++)
		{
//				cout << "j:" << j << " now:" << came[j] << " size:" << came.size() << " " << i << endl;
			if(i==came[j])
			{
				i++;
				j=-1;
			}
		}
		if(i==n)
			break;
//		cout << "next:" << i << endl;
		came.push_back(i);
		serch(loop+1,sans+str[i]);
		came.pop_back();
	}
	return ;
}

int main()
{
	int i,j;
	for(;;)
	{
		cin >> n >> m ;
		if(n==0 && m==0)
			break;
		
		ans.clear();
		
		for(i=0;i<n;i++)
			cin >> str[i] ;
		
		serch(0,"");
		
		cout << ans.size() << endl;
	}
}