#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int n, k;
  while (true) {
    cin >> n >> k;
    if (n == 0 && k == 0) return 0;
    vector<string> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    set<string> s;
    do {
      string ans;
      rep(i, k) ans += a[i];
      s.insert(ans);
    } while (next_permutation(a.begin(), a.end()));

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

