from collections import deque N,M = map(int,input().split()) S = [] def tmp(x): return ord(x) -ord('a') for _ in range(N): s = list(map(tmp,list(input()))) S.append(s) def check(s,t): l = 0 cnt = 0 for i in range(len(s)): if s[i] == t[l]: l += 1 else: l += 1 if cnt: return False if s[i] == t[l]: l+=1 cnt += 1 else: return False return True def f(m,x,s0): return s0[:m] + [x] + s0[m:] def allcheck(t): for i in range(N): if check(S[i],t): pass else: return False return True ans = 0 for m in range(M+1): for x in range(26): t = f(m,x,S[0]) if allcheck(t): ans += 1 print(ans)