#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <queue>
#include <set>

#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

set<string> s;
int trace[4];
bool used[10];

void dfs(int depth, int n, int k, vector<int>& num) {
    if (depth == k) {
        stringstream ss;
        rep(i,k)ss << num[trace[i]];
        s.insert(ss.str());
    } else {
        rep(i,n) {
            if (used[i])continue;
            used[i] = true;
            trace[depth] = i;
            dfs(depth + 1, n, k, num);
            used[i] = false;
        }
    }
}

int main() {
    int n,k;
    while(cin >> n >> k, n) {
        s.clear();
        vector<int> num(n);
        rep(i,n) cin >> num[i];
        dfs(0, n, k, num);
        cout << s.size() << endl;
    }
    return 0;
}