A router groups incoming URL route segments (each a string of lowercase English letters) and wants to know how much of a leading path they all share. Compute the length of the longest common prefix of all n given segments: the largest L such that the first L characters of every segment are identical. If the segments share no leading character, the answer is 0.
Input format
Line 1: an integer n, the number of segments.
Next n lines: one segment per line, each a non-empty string of lowercase English letters.
Output format
A single integer: the length of the longest common prefix of all n segments.
Constraints
- 1 <= n <= 1000
- 1 <= length of each segment <= 1000
- Each segment consists only of lowercase English letters (
a-z).