// Arup Guha
// 4/22/2021
// Solution to 2021 NADC Problem H: Longest Common Substring

import java.util.*;

public class h {

	public static void main(String[] args) {
	
		// Get input.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int minL = 100;
		String[] list = new String[n];
		for (int i=0; i<n; i++) {
			list[i] = stdin.next();
			minL = Math.min(minL, list[i].length());
		}
			
		// Binary search the length.
		int low = 0, high = minL;
		while (low < high) {
			
			int mid = (low+high+1)/2;
			
			// Update low or high accordingly.
			if (canDo(mid, list))
				low = mid;
			else
				high = mid-1;
		}
		
		// Ta da!
		System.out.println(low);
	}
	
	// Returns true iff there is a substring of length len in each string in list.
	public static boolean canDo(int len, String[] list) {
	
		// These are the candidates.
		HashSet<String> set = new HashSet<String>();
		for (int i=0; i<=list[0].length()-len; i++)
			set.add(list[0].substring(i, i+len));
	
		// And with the rest...
		for (int idx=1; idx<list.length; idx++) {
		
			// Go through and see which substrings of this string are in our master list.
			HashSet<String> tmp = new HashSet<String>();
			for (int i=0; i<=list[idx].length()-len; i++) {
				String item = list[idx].substring(i, i+len);
				if (set.contains(item))
					tmp.add(item);
			}
		
			set = tmp;
			if (set.size() == 0) return false;
		}
		
		// If we get here, we are good.
		return true;
	}
}