#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int N, K;
int card[10];
bool used[10];
set<int> s;

int keta(int n) {
	int tmp = 1;
	while (n != 0)
	{
		n /= 10;
		tmp *= 10;
	}
	return tmp;
}

void solve(int m, int l) {
	if (m == K) {
		s.insert(l);

		return;
	}

	for (int i = 0; i < N; i++) {
		if (used[i] == false) {
			used[i] = true;
			solve(m + 1, l*keta(card[i]) + card[i]);
			used[i] = false;
		}
	}
}

int main() {

	while (cin >> N >> K, N)
	{
		s.clear();

		for (int i = 0; i < N; i++) {
			cin >> card[i];
			used[i] = false;
		}

		for (int i = 0; i < N; i++) {
			used[i] = true;
			solve( 1, card[i]);
			used[i] = false;
		}


		cout << s.size() << endl;
	}


	return 0;
}


