#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;

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

int n, k;
vector<string> cards;
set<string> ans;

void dfs(vector<int> s, set<int> used)
{
    if (s.size() == k)
    {
        string str = "";
        for (int i : s)
        {
            str += cards[i];
        }
        ans.emplace(str);
        return;
    }
    rep(i, n)
    {
        if (used.count(i) == 0)
        {
            vector<int> s2 = s;
            s2.push_back(i);
            set<int> used2 = used;
            used2.emplace(i);
            dfs(s2, used2);
        }
    }
}

int main()
{
    while (true)
    {
        ans = {};
        cin >> n >> k;
        if (n + k == 0)
        {
            break;
        }
        cards.resize(n);
        rep(i, n)
        {
            cin >> cards[i];
        }

        dfs({}, {});
        cout << ans.size() << endl;
    }
}
