#!/usr/bin/env python3

from collections import defaultdict


def main():
    n = int(input())
    s = [input() for _ in range(n)]

    m = len(s[0])

    lo = 0
    hi = m + 1
    while lo + 1 < hi:
        mid = (lo + hi) // 2
        valid = any(
            all(s[0][i : i + mid] in t for t in s[1:]) for i in range(m - mid + 1)
        )
        if valid:
            lo = mid
        else:
            hi = mid

    print(lo)


if __name__ == "__main__":
    main()
