#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

struct Info{
	int number;
};

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

//base??¨comp??????????????????????????¢??°
bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

void func(int n,int k){

	Info info[5041];
	int index = 0,cards[10],tmp;

	for(int i = 0; i < n; i++)scanf("%d",&cards[i]);

	//k????????????????????¶?????°
	if(k == 2){

		for(int i = 0; i < n; i++){
			for(int k = 0; k < n; k++){
				if(i != k){
					//???????????°??????????????????
					if(cards[k] >= 10){
						tmp = 100*cards[i] + cards[k];
					}else{
						tmp = 10*cards[i] + cards[k];
					}

					if(index == 0){
						info[0].number = tmp;
						index++;
					}else{ //??¢??????????????????????????°??¨?????????????????????
						bool Found = false;
						for(int p = 0; p < index; p++){
							if(info[p].number == tmp){
								Found = true;
								break;
							}
						}
						if(!Found){ //?????¨???????????´???????????????
							info[index].number = tmp;
							index++;
						}
					}
				}
			}
		}

		printf("%d\n",index);
	}else if(k == 3){
		for(int i = 0; i < n; i++){
			for(int k = 0; k < n; k++){
				for(int a = 0; a < n; a++){
					if(i != k && i != a && k != a){
						//???????????°??????????????????
						if(cards[a] >= 10){
							tmp = 100*cards[k] + cards[a];
						}else{
							tmp = 10*cards[k] + cards[a];
						}

						if(tmp <= 99){ //2???
							tmp += 100*cards[i];
						}else if(tmp <= 999){ //3???
							tmp += 1000*cards[i];
						}else{ //4???
							tmp += 10000*cards[i];
						}

						if(index == 0){
							info[0].number = tmp;
							index++;
						}else{ //??¢??????????????????????????°??¨?????????????????????
							bool Found = false;
							for(int p = 0; p < index; p++){
								if(info[p].number == tmp){
									Found = true;
									break;
								}
							}
							if(!Found){ //?????¨???????????´???????????????
								info[index].number = tmp;
								index++;
							}
						}
					}
				}
			}
		}
		printf("%d\n",index);
	}else{ //k == 4
		for(int i = 0; i < n; i++){
			for(int k = 0; k < n; k++){
				for(int a = 0; a < n; a++){
					for(int b = 0; b < n; b++){
						if(i != k && i != a && i != b && k != a && k != b && a != b){
							//???????????°??????????????????
							if(cards[b] >= 10){
								tmp = 100*cards[a] + cards[b];
							}else{
								tmp = 10*cards[a] + cards[b];
							}

							if(tmp <= 99){ //2???
								tmp += 100*cards[k];
							}else if(tmp <= 999){ //3???
								tmp += 1000*cards[k];
							}else{ //4???
								tmp += 10000*cards[k];
							}

							if(tmp <= 999){ //3???
								tmp += 1000*cards[i];
							}else if(tmp <= 9999){ //4???
								tmp += 10000*cards[i];
							}else if(tmp <= 99999){ //5???
								tmp += 100000*cards[i];
							}else{ //6???
								tmp += 1000000*cards[i];
							}
							if(index == 0){
								info[0].number = tmp;
								index++;
							}else{ //??¢??????????????????????????°??¨?????????????????????
								bool Found = false;
								for(int p = 0; p < index; p++){
									if(info[p].number == tmp){
										Found = true;
										break;
									}
								}
								if(!Found){ //?????¨???????????´???????????????
									info[index].number = tmp;
									index++;
								}
							}
						}
					}
				}
			}
		}
		printf("%d\n",index);
	}
}


int main(){

	int n,k;

	while(true){
		scanf("%d %d",&n,&k);

		if(n == 0 && k == 0)break;

		func(n,k);
	}

    return 0;
}
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int cards[10];
set<int> nums;
int n;

void f(int m,int k,int used){
	if(k==0){
		nums.insert(m);
		return;
	}
	int i;
	for(i=0;i<n;i++){
		if(used&1<<i)continue;
		f(m*(cards[i]<10?10:100)+cards[i],k-1,used|1<<i);
	}
}

int main() {
	int k;
	while(n=in(),k=in()){
		nums.clear();
		int i;
		for(i=0;i<n;i++){
			cards[i]=in();
		}
		f(0,k,0);
		cout<<nums.size()<<endl;
	}
	return 0;
}