#include <iostream>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int n,k;
    string card[10];
    while(cin>>n>>k,n){
        set<string> s;
        for(int i=0;i<n;++i) cin>>card[i];
        sort(card,card+n);
        do{
            string cb;
            for(int i=0;i<k;++i) cb +=card[i];
            s.insert(cb);
        }while(next_permutation(card,card+n));
        cout<<s.size()<<endl;
    }
    return 0;
}