import collections n = int(input()) s_list = [input() for i in range(n)] max_freq = -1 max_key = -1 s_clc = collections.Counter(s_list) for key in s_clc.keys(): if s_clc[key] > max_freq: max_freq = s_clc[key] max_key = len(key) elif s_clc[key] == max_freq and len(key) > max_key: max_key = len(key) print(max_key - 2)