import sys from collections import defaultdict def main(): N, M = map(int, sys.stdin.readline().split()) S_list = [sys.stdin.readline().strip() for _ in range(N)] count = defaultdict(int) for s in S_list: seen = set() for pos in range(M + 1): for c in 'abcdefghijklmnopqrstuvwxyz': # Generate T by inserting c at position pos t = s[:pos] + c + s[pos:] if t not in seen: seen.add(t) count[t] += 1 result = 0 for t, cnt in count.items(): if cnt == N: result += 1 print(result) if __name__ == "__main__": main()