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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class a {
    /*
     * In a Programming contest, you are expected to print the output at the
     * end, so `output` variable will hold all the processed results till the
     * end
     */
    public static String output = "";

    // Program's starting point
    public static void main(String[] args) {

        /*
         * A Scanner class slows down Input/Output a LOT ,thereby increasing
         * your code execution time , Hence for best results that is Fast I/O
         * try to use BufferedReader
         */
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        /*
         * Generally Code Chef, Hacker Rank gives X number of test cases so we
         * process the input for each.
         */
        final int cases;
        try {
            int n = Integer.parseInt(br.readLine());

            /*
             * Logic of the program must be separated from the meta code to
             * increase readability and help debugging easier
             * Also note that Solver object is created inside for loop to
             * avoid multiple object creation that drastically increases
             * execution time and memory usage
             */
            Solver solver = new Solver();
            String[] phonenumbers = new String[n];
            for (int i = 0; i < n; i++) {
                phonenumbers[i] = br.readLine();
            }
            solver.solve(n, phonenumbers);

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        // Print the final output
        System.out.println(output);
    }
}

class Solver {

    /*
     * Logic goes here ...
     * Add to the global variables after processing the input
     * Maybe reverse a string or parse to an integer or , etc.
     */

    public void solve(int n, String[] phonenumbers) {
        int length = 0;
        for(int j = 0; j < phonenumbers[0].length(); j++) {
            char c = phonenumbers[0].charAt(j);
            for(int i = 1; i < n; i++) {
                if(phonenumbers[i].charAt(j) != c) {
                    a.output = a.output.concat(String.valueOf(length));
                    return;
                }
            }
            length++;
        }
        a.output = a.output.concat(String.valueOf(length));
    }
}

