#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()

#define MAX_N 11

int n, k;
int list[MAX_N];

int solve() {

  int ans = 0;
  vector<int> v;
  do {
    int score = 0;
    rep(i, k) {
      int x = list[i];
      if (x < 10) score = score*10 + x;
      else        score = score*100 + x;
    }
    if (!binary_search(v.begin(), v.end(), score)) {
      ans++;
      v.push_back(score);
      sort(v.begin(), v.end());
    }
  } while (next_permutation(list, list+n));
  return ans;
}

int main() {
  while (true) {
    cin >> n >> k;
    if (n == 0 && k == 0) break;
    rep(i, n) cin >> list[i];
    sort(list, list+n);

    cout << solve() << '\n';
  }
  return 0;
}