from itertools import permutations as P



while True:

    n, k = int(eval(input())), int(eval(input()))

    if k == 0:

        break

    card = [int(eval(input())) for _ in range(n)]

    print((len(set([''.join(map(str, s)) for s in set(P(card, k))]))))
from itertools import permutations as P



while True:

    n, k = int(eval(input())), int(eval(input()))

    if k == 0:

        break

    card = [eval(input()) for _ in range(n)]

    print((len(set([''.join(s) for s in P(card, k)]))))
from itertools import permutations as P

while True:
    n, k = int(eval(input())), int(eval(input()))
    if k == 0:
        break
    card = [int(eval(input())) for _ in range(n)]
    print((len(set(["".join(map(str, s)) for s in set(P(card, k))]))))

from itertools import permutations as P

while True:
    n, k = int(eval(input())), int(eval(input()))
    if k == 0:
        break
    card = [eval(input()) for _ in range(n)]
    print((len(set(["".join(s) for s in P(card, k)]))))

-    card = [int(eval(input())) for _ in range(n)] -    print((len(set(["".join(map(str, s)) for s in set(P(card, k))])))) +    card = [eval(input()) for _ in range(n)] +    print((len(set(["".join(s) for s in P(card, k)]))))