def is_one_char_deletion(T, S): len_T = len(T) len_S = len(S) if len_T != len_S + 1: return False i = j = 0 allowed_skips = 1 while i < len_S and j < len_T: if S[i] == T[j]: i += 1 j += 1 else: if allowed_skips: allowed_skips -= 1 j += 1 else: return False # Handle remaining characters if allowed_skips: # Check if the remaining characters in T are one more than S return i == len_S and j == len_T - 1 return i == len_S and j == len_T def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 M = int(input[idx]) idx += 1 S_list = [] for _ in range(N): S = input[idx] idx += 1 S_list.append(S) if N == 0: print(0) return first_S = S_list[0] possible_T = set() # Generate all possible T by inserting one character into first_S for pos in range(M+1): for c in 'abcdefghijklmnopqrstuvwxyz': new_T = first_S[:pos] + c + first_S[pos:] possible_T.add(new_T) count = 0 for T in possible_T: valid = True for S in S_list: if not is_one_char_deletion(T, S): valid = False break if valid: count += 1 print(count) if __name__ == "__main__": main()