n,k = map(int,input().split()) S = [list(map(int,input())) for i in range(n)] M = 5**k high = [0]*M def cost(s): c = 0 for i in s: c *= 5 c += i return c for s in S: c = cost(s) high[c] += 1 for i in range(k): di = 5**i mod = 5**(i+1) for j in range(M)[::-1]: x = j%mod x //= di if x == 0: continue high[j-di] += high[j] ans = 0 for s in S: c = cost(s) if high[c] > 1: ans += 1 print(ans)