#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n, k;
    while(cin >> n >> k) {
        if (n == 0) break;
        vector<int> card(n);
        rep(i, n) {
            cin >> card[i];
        }
        
        sort(card.begin(), card.end());
        set<int> ans;
        int sum;
        do {
            sum = 0;
            rep(i, k) {
                if (card[i] < 10) {
                    sum = 10 * sum + card[i];
                } else {
                    sum = 100 * sum + card[i];
                }
            }
            ans.insert(sum);
        } while (next_permutation(card.begin(), card.end()));

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