#!python3
def solve():
  n = int(input())
  l = [input() for _ in range(n)]
  ret = 0
  for cand in range(len(l[0]), -1, -1):
    if cand <= ret:
      break
    for i in range(len(l[0])-cand+1):
      force = l[0][i:i+cand]
      if all([force in x for x in l]):
        ret = cand
        break
  print(ret)

solve()