#include <stdio.h>
#include <string.h>
#include <algorithm>

int N, K;
char A[11][10];
int used[11];
char num[100];
int size, arr[6000];
int ans = 0;

void rec(int k) {
	int length = strlen(num);
	if (k == K) {
		arr[size++] = atoi(num);
		return;
	}
	for (int i = 0; i < N; ++i) {
		if (!used[i]) {
			used[i] = 1;
			strcat(num, A[i]);
			rec(k + 1);
			used[i] = 0;
			num[length] = '\0';
		}
	}
}

void bubbleSort() {
	for (int i = 0; i < size; ++i) {
		for (int j = 1; j < size - i; ++j) {
			if (arr[j - 1] > arr[j]) {
				std::swap(arr[j - 1], arr[j]);
			}
		}
	}
}

int main(void) {
	while (true) {
		scanf("%d%d", &N, &K);
		if (N == 0 && K == 0) { break; }
		for (int i = 0; i < N; ++i) { scanf("%s", &A[i]); }

		for (int i = 0; i < N; ++i) { used[i] = 0; }
		strcpy(num, "");
		size = 0;
		rec(0);
		bubbleSort();
		ans = 0;
		for (int i = 0; i < size; ++i) {
			if (i == 0 || arr[i - 1] != arr[i]) { ans++; }
		}
		printf("%d\n", ans);
	}
	return 0;
}