#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

const int MAXN = 10;
int N;
bool used[MAXN];
string A[MAXN];
set<int> vis;

void rec(string num, int k) {
  if(k == 0) {
    vis.insert(atoi(num.c_str()));
    return;
  }
  for(int i = 0; i < N; ++i) {
    if(used[i]) continue;
    used[i] = true;
    rec(num+A[i], k-1);
    used[i] = false;
  }
}

int main() {
  int k;
  while(cin >> N && N) {
    cin >> k;
    for(int i = 0; i < N; ++i) {
      cin >> A[i];
    }
    vis.clear();
    rec("", k);
    cout << vis.size() << endl;
  }
  return 0;
}