#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define rep(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define rrep(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;
    
    while(cin>>N>>K,N!=0&&K!=0){
        set<string> num;
        vector<string> card(N);
        rep(i,0,N) cin>>card[i];
        sort(all(card));

        do{
            string s = "";
            rep(i,0,K) s += card[i]; 
            num.insert(s);
        }while(next_permutation(all(card)));
        put(num.size());
    }
}

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int n, k;
  while(cin >> n, n) {
    cin >> k;
    set<string> SET;
    vector<string> vs(n); FOR(i,0,n) cin >> vs[i];
    FOR(i,0,1<<n) {
      vector<int> v;
      int cnt = 0;
      FOR(j,0,n) {
        if((i>>j)&1) {
          cnt++;
          v.push_back(j);
        }
      }
      if(cnt != k) continue;
      do {
        string s = "";
        FOR(l,0,k) s = s + vs[v[l]];
        SET.insert(s);
      } while(next_permutation(v.begin(), v.end()));
    }
    cout << SET.size() << endl;
  } 
  
  return 0;
}