#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n,k;
ll a[20];
bool used[20];

ll ans;
map<ll,bool> mp;

void dfs(ll now, ll num){
	if(now == k){
		if(!mp[num]){
			mp[num] = true;
			ans++;
			//cout << num << "num" << endl;
		}
	}
	for (int i = 0;i < n;i++){
		if(!used[i]){
			ll nn;
			if(a[i] >= 10) nn = num * 100;
			else nn = num * 10;
			nn += a[i];
			used[i] = true;
			dfs(now+1,nn);
			used[i] = false;
		}
	}
	return;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while(true){
		cin >> n;
		if(n == 0) break;
		cin >> k;

		for (int i = 0;i < n;i++){
			cin >> a[i];
		}

		memset(used,0,sizeof(used));
		mp = map<ll,bool>();
		ans = 0;
		
		dfs(0,0);

		cout << ans << endl;

	}

	return 0;

}


#include <bits/stdc++.h>
using namespace std;
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
 
#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
 
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  int N, K;
while(
  cin >> N >> K,N){
  VI xs(N);
  REP(i,N) cin >> xs[i];
 
  SORT(xs);
  set<int> ans;
  do{
	int s = 0;
	REP(i,K){
	  s = s * (xs[i] >= 10? 100: 10) + xs[i];
	}
	ans.insert(s);
  }while(next_permutation(ALL(xs)));
 
  cout << SZ(ans) << endl;
 }
  return 0;
}