Polycarpus has n friends in Tarasov city. Polycarpus knows phone numbers of all his friends: they are strings s1, s2, ..., sn. All these strings consist only of digits and have the same length. 

Once Polycarpus needed to figure out Tarasov city phone code. He assumed that the phone code of the city is the longest common prefix of all phone numbers of his friends. In other words, it is the longest string c which is a prefix (the beginning) of each si for all i (1 ≤ i ≤ n). Help Polycarpus determine the length of the city phone code. 

Input

The first line of the input contains an integer n (2 ≤ n ≤ 3·104) — the number of Polycarpus's friends. The following n lines contain strings s1, s2, ..., sn — the phone numbers of Polycarpus's friends. It is guaranteed that all strings consist only of digits and have the same length from 1 to 20, inclusive. It is also guaranteed that all strings are different.

Output

Print the number of digits in the city phone code.

Examples

Input

4
00209
00219
00999
00909


Output

2


Input

2
1
2


Output

0


Input

3
77012345678999999999
77012345678901234567
77012345678998765432


Output

12

Note

A prefix of string t is a string that is obtained by deleting zero or more digits from the end of string t. For example, string "00209" has 6 prefixes: "" (an empty prefix), "0", "00", "002", "0020", "00209".

In the first sample the city phone code is string "00".

In the second sample the city phone code is an empty string.

In the third sample the city phone code is string "770123456789".
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;


 
public class Main {

	
	class Node{
		int value, nuOfC=0, done=0;
		List<Integer> connections;
		
		public Node(){
			connections = new ArrayList<Integer>();
		}

		public int getValue() {
			return value;
		}

		public void setValue(int value) {
			this.value = value;
		}

		public int getNuOfC() {
			return nuOfC;
		}

		public void setNuOfC(int nuOfC) {
			this.nuOfC = nuOfC;
		}

		public List<Integer> getConnections() {
			return connections;
		}

		public void setConnections(List<Integer> connections) {
			this.connections = connections;
		}
		
	}
	
	
	class Net{
		HashMap <Integer, Node> map;
		
		public Net(){
			map = new HashMap <Integer, Node>(); 
		}
		
		public void addNode(int val){
			Node node= new Node();
			node.setValue(val);
			map.put(val, node);
		}

		public void editNode(int from, int to) {
			Node node = map.get(from);
			node.nuOfC++;
			node.connections.add(to);
			map.replace(from, node);
		}

		
		public int getMax() {
			int ret = 1;
			while (true){
				int max=-1111, idx = -1;
				for (int i = 0;i<=map.size();i++){
					if (map.containsKey(i) && map.get(i).nuOfC > max && map.get(i).done == 0){
						max = map.get(i).nuOfC;
						idx = i;
					}
				}
				System.out.println(idx);
				if (idx == -1)
					break;
				List<Integer> list = map.get(idx).connections;
				Node nn = map.get(idx);
				nn.done = 1;
				map.replace(idx, nn);
				for (int i = 0 ; i <  map.get(idx).nuOfC ; i++){
					ret*=2;
				}
				HashMap <Integer, Node> map1 = new HashMap <Integer, Node>();
				for (int i = 0 ; i < list.size() ; i++){
					Node nod = map.get(list.get(i));
					if (nod!=null && nod.done==0){
						nod.nuOfC--;
						map1.put(list.get(i), nod);
					}
				}
				map = map1;
			}
			return ret;
		}
	}
	

	private static int doIt(int i, int j, int res) {
		System.out.println(i + "    " + j + "    " + res);
		if (i == j)
			return res;
		if (i<=0 || j<=0)
			return -1;
		if (i %2==0){
			if (j%2==0){
				doIt(i, j/2,res+1);
				doIt(i/2, j/2,res+1);
			}
			if (j%3==0){
				doIt(i, j/3,res+1);
				doIt(i/2, j/3,res+1);
			}
			if (j%5==0){
				doIt(i, j/5,res+1);
				doIt(i/2, j/5,res+1);
			}
		}
		if (i %3==0){
			if (j%2==0){
				doIt(i, j/2,res+1);
				doIt(i/3, j/2,res+1);
			}
			if (j%3==0){
				doIt(i, j/3,res+1);
				doIt(i/3, j/3,res+1);
			}
			if (j%5==0){
				doIt(i, j/5,res+1);
				doIt(i/3, j/5,res+1);
			}
		}if (i %5==0){
			if (j%2==0){
				doIt(i, j/2,res+1);
				doIt(i/5, j/2,res+1);
			}
			if (j%3==0){
				doIt(i, j/3,res+1);
				doIt(i/5, j/3,res+1);
			}
			if (j%5==0){
				doIt(i, j/5,res+1);
				doIt(i/5, j/5,res+1);
			}
		}
		return -54;
		
			
	}

	// 200000000 150000000
	public int min = 1000000000;
	public int no = -1;
	public void doIT(int a, int b, int co){
		//System.out.println(a + "          " + b);
		if (a==b){
			min = Math.min(co,min);// System.out.println(co);
			System.out.println(co + "     " + min);
			no = 1;
		}
		if (a>b){
			if (a%2==0){
				doIT(a/2,b,co+1);
			}
			if (a%3==0){
				doIT(a/3,b,co+1);
			}
			if (a%5==0){
				doIT(a/5,b,co+1);
			}
		}else if (a<b){
			if (b%2==0){
				doIT(a,b/2,co+1);
			}
			if (b%3==0){
				doIT(a,b/3,co+1);
			}
			if (b%5==0){
				doIT(a,b/5,co+1);
			}
		}
	}
	

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		
		
		
		
		
		/*
		
		// 46A
		int n = in.nextInt();
		int inc=1;
		for (int i = 1 ; i < n;i++){
			System.out.print((i+inc)%n + " ");
			inc =(i+inc)%n;
		}
		
		*/
		
		
		
		//172A	
		int n = in.nextInt();
		int idx=20;
		String prev = null;
		for (int i = 0 ; i < n ; i ++){
			String h = in.next();
			if (i==0){
				idx = h.length();
				prev=h;
			}
			else{
				for (int j = 0; j < idx ; j ++){
					if (h.charAt(j)!=prev.charAt(j)){
						idx = j;
						prev = h;
					}
				}
			}
		}
		System.out.println(idx);
		
		
/*		
		//371B
		Main main = new Main();
		int a=in.nextInt(),b=in.nextInt();
		main.doIT(a, b, 0);
		if (main.no!=-1){
			System.out.println(main.min);
		}else
			System.out.println(-1);
		*/
	
	
		/*
		// 5A
	 	String h;
		int l = 0;
		int alive =0;
		while((h = in.nextLine()) != null){
			if (h.charAt(0) == '+'){
				alive++;
			}
			else if (h.charAt(0) == '-'){
				alive--;
			}else{
				int idx = h.indexOf(':');
				int msg = ((int)h.length()) - idx-1;
				l += (msg*alive);
			}
		}
		System.out.println(l);
*/
		
		
/*	
		// 445B
		int n = in.nextInt(), m = in.nextInt();
		int [] arr= new int[n+1];
		int ret = (int)Math.pow(2, n-1);
		for (int i = 1 ; i <=m ;i++){
			int e = in.nextInt(), g = in.nextInt();
			arr[e] = 1;
			arr[g] = 1;
		}
		int cou = 0;
		for (int i = 1 ; i <= n ; i++){
			if (arr[i] != 1)
				cou++;
		}
		if (m!=0)
		for (int i = 0 ; i  < cou ; i ++)
			ret/=2;
		
		System.out.println(ret);
		
		
*/

		
		
		
		/*		
		//         	
	    string n; int k;
	    cin >> n >> k;
	    
	    for (int i = 0 ; i < n.size()-1 ; i++){
			if (n[i] < n[i+1] && k>0){
				char h = n[i];
				n[i] = n[i+1];
				n[i+1] = h;
				k--;
				for (int j = i ; j > 0 ; j--){
					if (n[j] > n[j-1] && k>0){
						char h = n[j];
						n[j] = n[j-1];
						n[j-1] = h;
						k--;
					}
				}
			}
			if (k==0)
				break;
		}
	    cout << n;*/
		
/*		 // 584C
		int n= in.nextInt(), m= in.nextInt();
		String s1 = in.next(), s2 = in.next();
		int same = 0;
		for (int i = 0 ; i < n ; i++){
			if (s1.charAt(i) == s2.charAt(i)){
				same++;
			}
		}
		
		if (same <= m ){
			System.out.println(-1);
			System.exit(0);
		}
*/
		
/*
		int w = in.nextInt(), h = in.nextInt(), n = in.nextInt();
		
		int arrw[] = new int[200001];
		int arrh[] = new int[200001];
		arrw[0]=1;
		arrh[0]=1;
		for (int i = 0 ; i < 4 ; i++){
			String dir = in.next();
			int num = in.nextInt();
			
			
			
			System.out.println(dir+"           "+num);
			
			
			
			if (dir.equals("H")){
				arrw[num] = 1;
			}else{
				arrh[num] = 1;
			}
			
			
			int maxw=-1231233,maxh=-1212121;
			int id = -1,idx=-1;
			for (int p = 0 ; p < 200001;p++){
				if (arrw[p]==1){
					if (id !=-1){
						maxw = Math.max(maxw, p-id);
					}
					id = p;
				}
				if (arrh[p]==1){
					if (idx !=-1){
						maxh = Math.max(maxh,p-idx);
					}
					idx = p;
				}
			}

			
			
			System.out.println(maxh * maxw);
		}
		
*/
		
		
		
		
/*
		// 614/B
		int n ;
		n = in.nextInt();
		BigInteger z = new BigInteger("10");
		String h = "";String ret = "";
		for (int j = 0 ;j < n ; j++){
			h += in.next();
			h+= " ";
		}
		

		Scanner im = new Scanner(h);
		int ind= 0;
		while(im.hasNext()){
			BigInteger g = new BigInteger(im.next());
			
			BigInteger y =z.pow(g.toString().length()-1);
			if (g.subtract(y).compareTo( BigInteger.ZERO ) == 1){
				System.out.print(g);
				String q = g.toString();
				for (int o = q.length()-1 ; o >=0 ; o--){
					if (q.charAt(o) == '0'){
						ind++;
					}
					if (q.charAt(o) != '0'){
						break;
					} 
				}
				break;
			}
		}
		im.close();

		
		int ones = 1;
		for (int i = h.length()-1 ; i>=0 ; i--){
			
			if (h.charAt(i) != '0'){
				ones=0;
			}
			if (h.charAt(i) == ' '){
				ones = 1;
			}
			if (h.charAt(i) == '0' && ones == 1 && i !=0 && h.charAt(i-1) != ' '){
				ret+='0';
			}
			if ( (h.charAt(i) == '0' && ones == 1 && i == 0) ||  (h.charAt(i) == '0' && ones == 1 && i != 0 && h.charAt(i-1) == ' ') ){
				System.out.println(0);
				in.close();
				System.exit(0);
			}

		}
System.out.println(ret.substring(0,ret.length()-ind));
*/
		
		
		
		in.close();
	}





}
