import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### n, k = na() s = [int(input()) for j in range(n)] se = set(s) ans = len(s)-len(se) from collections import * d = defaultdict(int) def saiki(p, now): global ans #print(p, now) if p == k: for i in range(5): if (now//(10**i))%(10**(i+1)): d[now] |= d[now-10**i] if now in se: ans += d[now] d[now] = 1 return for i in range(5): saiki(p+1, now * 10 + i) saiki(0,0) print(ans)