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.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

    FastScanner in = new FastScanner(System.in);
//    FastScanner in = new FastScanner(new File("test.txt"));
    
    PrintWriter out = new PrintWriter(System.out);

    public static void main (String[]args) throws IOException {
        Main task = new Main();
        task.solve();
        task.close();
    }

    public void close () {
        in.close();
        out.close();
    }
    
    public void solve() throws IOException {
        solveA();
    }
    
    public void solveA() {
        int n = in.nextInt();
        ArrayList<Character>answer = new ArrayList<Character>();
        ArrayList<String>list = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            list.add(in.next());
        }
        
        for (int i = 0; i < list.get(0).length(); i++) {
            HashSet<Character>set = new HashSet<Character>();
            for (int j = 0; j < list.size(); j++) {
                set.add(list.get(j).charAt(i));
            }
            if (set.size() == 1) answer.add(set.iterator().next());
            else {
                break;
            }
        }
        
        
        System.out.println(answer.size());
        
    }

    public void solveB() {
        int a = in.nextInt();
        int b = in.nextInt();
        int m = in.nextInt();
        int r0 = in.nextInt();
        
        ArrayList<Integer>list = new ArrayList<Integer>();
        int rprev = r0;
        for (int i = 0; i <= 2 * m + 1; i++) {
            int next = (a * rprev + b) % m;
            rprev = next;
//          System.out.print(next + " ");
            list.add(next);
        }
//      System.out.println();
        
        for (int i = 1; i <= m; i++) {
            int T = i;
            boolean flag = false;
            for (int j = list.size() - 1; j >= list.size() - 1 - T; j--) {
                if (j <= T) {
                    flag = true;
                    break;
                }
                int aa = list.get(j);
                int bb = list.get(j - T);
                
                if (aa != bb) {
                    flag = true;
                    break;
                }
                
            }
            if (!flag) {
                out.println(T);
                return;
            }
        }
        
        out.println(m);
        
    }
    
    public void solveC() {
        int n = in.nextInt();
        int m = in.nextInt();
        
        LinkedList<Student>list = new LinkedList<Student>();
        ArrayList<StudentID>answer = new ArrayList<StudentID>();
        
        for (int i = 0; i < n; i++) {
            Student st = new Student();
            st.setId(i);
            st.setT(in.nextInt());
            st.setX(in.nextInt());
            list.add(st);
        }
        
        Collections.sort(list);
        
        
        long TIME = 0;
        int POS = 0;
        
        while (list.size() != 0) {
            ArrayList<SimpleStudent>trip = new ArrayList<Main.SimpleStudent>();
            HashMap<Integer, Integer>map = new HashMap<Integer, Integer>();
            HashMap<Integer, Integer>changeble = new HashMap<Integer, Integer>();
            int qqq = list.size();
            for (int i = 0; i < Math.min(m, qqq); i++) {
                SimpleStudent ss = new SimpleStudent();
                Student s = list.removeFirst();
                ss.setId(s.getId());
                ss.setT(s.getT());
                ss.setX(s.getX());
                if (ss.getT() > TIME) TIME = ss.getT();
                POS = 0;
                trip.add(ss);
                if (map.containsKey(ss.getX())) {
                    map.put(ss.getX(), map.get(ss.getX()) + 1);
                }
                else {
                    map.put(ss.getX(), 1);
                }
                if (changeble.containsKey(ss.getX())) {
                    changeble.put(ss.getX(), changeble.get(ss.getX()) + 1);
                }
                else {
                    changeble.put(ss.getX(), 1);
                }
            }
            Collections.sort(trip);
            for (int i = 0; i < trip.size(); i++) {
                SimpleStudent ss = trip.get(i);
                TIME += ss.getX() - POS;
                POS = ss.getX();                
                
                StudentID an = new StudentID();
                an.setId(ss.getId());
                an.setX(ss.getX());
                an.setAnswer(TIME);
                int count = changeble.get(an.getX());
                count--;
                changeble.put(an.getX(), count);
                if (count == 0) {
                    TIME += 1 + map.get(an.getX()) / 2;
                }
                answer.add(an);
            }
            TIME += POS;            
        }
        
        Collections.sort(answer);
        for (int i = 0; i < answer.size(); i++) {
            out.print(answer.get(i).getAnswer() + " ");
        }
        
        
    }
    
    class SimpleStudent implements Comparable<SimpleStudent>{
        long t;
        int x;
        int id;
        int answer;
        public int getId() {
            return id;
        }
        public void setId(int id) {
            this.id = id;
        }
        public int getAnswer() {
            return answer;
        }
        public void setAnswer(int answer) {
            this.answer = answer;
        }
        @Override
        public int compareTo(SimpleStudent o) {
            if (o.x < this.x) return 1;
            else return -1;
        }
        public long getT() {
            return t;
        }
        public void setT(long t) {
            this.t = t;
        }
        public int getX() {
            return x;
        }
        public void setX(int x) {
            this.x = x;
        }
    }
    
    class StudentID implements Comparable<StudentID>{
        long t;
        int x;
        int id;
        long answer;
        public int getId() {
            return id;
        }
        public void setId(int id) {
            this.id = id;
        }
        public long getAnswer() {
            return answer;
        }
        public void setAnswer(long answer) {
            this.answer = answer;
        }
        @Override
        public int compareTo(StudentID o) {
            if (o.id < this.id) return 1;
            else return -1;
        }
        public long getT() {
            return t;
        }
        public void setT(long t) {
            this.t = t;
        }
        public int getX() {
            return x;
        }
        public void setX(int x) {
            this.x = x;
        }
    }
    
    class Student implements Comparable<Student>{
        long t;
        int x;
        int id;
        int answer;
        public int getId() {
            return id;
        }
        public void setId(int id) {
            this.id = id;
        }
        public int getAnswer() {
            return answer;
        }
        public void setAnswer(int answer) {
            this.answer = answer;
        }
        @Override
        public int compareTo(Student o) {
            if (o.t < this.t) return 1;
            else return -1;
        }
        public long getT() {
            return t;
        }
        public void setT(long t) {
            this.t = t;
        }
        public int getX() {
            return x;
        }
        public void setX(int x) {
            this.x = x;
        }
    }
}


class Algebra {
    /****
     *       Number of co-prime numbers on [1, n].
     *       Number a is Co-prime if gcd (a, n) == 1
     *       O (sqrt(n))
     ****/
    public static int phi(int n) {
        int result = n;
        for (int i = 2; i*i <= n; ++i) {
            if (n % i == 0) {
                while (n % i == 0) {
                    n /= i;
                }
                result -= result / i;
            }
        }
        if (n > 1) {
            result -= result / n;
        }
        return result;
    }

    /****
     *       Raise number a to power of n.
     *       O (log n)
     ****/
    public static int binpow (long a, int n) {
        int res = 1;
        while (n != 0) {
            if ((n & 1) == 1)
                res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    /****
     *       Finding the greatest common divisor of two numbers.
     *       O (log min(a, b))
     ****/
    public static int gcd (int a, int b) {
        return (b != 0) ? gcd (b, a % b) : a;
    }

    /****
     *       Finding the lowest common multiple of two numbers.
     *       O (log min(a, b))
     ****/
    public static int lcm (int a, int b) {
        return a / gcd (a, b) * b;
    }

    /****
     *       Eratosthenes Sieve of numbers - [0..n]. True - simple, False - not simple.
     *       O (n log log n)
     ****/
    public static boolean[] sieveOfEratosthenes (int n) {
        boolean [] prime = new boolean[n + 1];
        Arrays.fill(prime, true);
        prime[0] = prime[1] = false;
        for (int i=2; i<=n; ++i) {
            if (prime[i]) {
                if (i * 1L * i <= n) {
                    for (int j=i*i; j<=n; j+=i) {
                        prime[j] = false;
                    }
                }
            }
        }
        return prime;
    }    
}

class FastScanner {
    BufferedReader br;
    StringTokenizer st;
    
    FastScanner(File f) {
        try {
            br = new BufferedReader(new FileReader(f));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
    
    FastScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
    }
    
    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                System.err.println(e);
                return "";
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    float nextFloat() {
        return Float.parseFloat(next());
    }
    BigInteger nextBigInt() {
        return new BigInteger(next());
    }

    void close() {
        try {
            br.close();
        }
        catch (IOException e) {
        }
    }
}