""" """ import sys from sys import stdin def encode(lis): now = 0 for j in range(K): now *= 5 now += int(lis[j]) return now N,K = map(int,stdin.readline().split()) S = [ list(stdin.readline()[:-1]) for i in range(N) ] dp = [0] * (5**K) for i in range(N): now = 0 for j in range(K): now *= 5 now += int(S[i][j]) dp[now] += 1 for i in range(len(dp)-1,-1,-1): dec = [] itmp = i for j in range(K): dec.append(itmp % 5) itmp //= 5 dec.reverse() #print (i,dec,"qopqowq") for j in range(K): dec[j] -= 1 if dec[j] >= 0: enc = encode(dec) #print (i,dec,enc) dp[enc] += dp[i] dec[j] += 1 ans = 0 for i in range(N): now = 0 for j in range(K): now *= 5 now += int(S[i][j]) if dp[now] > 1: ans += 1 #print (dp) print (ans)