#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

int popcnt(int x){
	int cnt = 0;
	while(x){
		x &= x-1;
		cnt++;
	}
	return cnt;
}

int main(){
    int n, k;
	while(cin >> n >> k, n|k){
		vector<string> v(n);
		set<string> s;
		rep(i, n) cin >> v[i];
		for(int i = 0; i < (1<<n); i++){
			if(popcnt(i) != k) continue;
			vector<string> sub;
			rep(j, n){
				if((i>>j)&1) sub.push_back(v[j]);
			}
			sort(all(sub));
			do{
				string x;
				rep(j, k){
					x += sub[j];
				}
				s.insert(x);
			}while(next_permutation(all(sub)));
		}
		cout << s.size() << endl;
	}
    return 0;
}