import sys def main(): input = sys.stdin.read().split() idx = 0 N, M = int(input[idx]), int(input[idx+1]) idx += 2 input_set = set() input_list = [] for _ in range(N): s = input[idx] idx += 1 input_set.add(s) input_list.append(s) valid_t = set() seen_candidates = set() for s in input_list: s_len = len(s) # Generate all possible T_candidate by inserting a character into s for pos in range(s_len + 1): for c in 'abcdefghijklmnopqrstuvwxyz': # Create candidate T t_candidate = s[:pos] + c + s[pos:] if t_candidate in seen_candidates: continue seen_candidates.add(t_candidate) # Check if all input strings are deletions of t_candidate all_valid = True for check_s in input_list: if len(check_s) != M: all_valid = False break if not is_deletion(check_s, t_candidate): all_valid = False break if all_valid: valid_t.add(t_candidate) print(len(valid_t)) def is_deletion(s, t): if len(s) != len(t) - 1: return False i = j = 0 skipped = False while i < len(s) and j < len(t): if s[i] == t[j]: i += 1 j += 1 else: if not skipped: skipped = True j += 1 else: return False # Check remaining characters in t if needed if not skipped: j += 1 # Ensure all of s is matched and exactly one character skipped return i == len(s) and j == len(t) if __name__ == "__main__": main()