import sys from collections import defaultdict def main(): N, M = map(int, sys.stdin.readline().split()) S = [sys.stdin.readline().strip() for _ in range(N)] if N == 0: print(0) return # Function to generate all possible T's by inserting one character into s def generate_T(s): possible = set() for i in range(len(s)+1): for c in 'abcdefghijklmnopqrstuvwxyz': new_s = s[:i] + c + s[i:] possible.add(new_s) return possible # Generate all possible T's for each S_i T_sets = [] for s in S: T_set = generate_T(s) T_sets.append(T_set) # Early exit if any T_set is empty if not T_set: print(0) return # Compute intersection of all T_sets common = T_sets[0] for t_set in T_sets[1:]: common.intersection_update(t_set) if not common: print(0) return print(len(common)) if __name__ == "__main__": main()