#include<iostream>
#include<string>
#include<set>
using namespace std;
int f[10],n,k;
string v[10];
set<string>u;
void F(int d,string s)
{
	if(d==k)u.insert(s);
	else for(int i=0;i<n;++i)
		if(!f[i])
		{
			f[i]=1;
			F(d+1,s+v[i]);
			f[i]=0;
		}
}
int main()
{
	int i;
	string s;
	while(cin>>n>>k,n)
	{
		for(i=0;i<n;++i)cin>>s,v[i]=s;
		u.clear();
		F(0,"");
		cout<<u.size()<<endl;
	}
	return 0;
}