public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner scan = new Scanner(System.in);
        int testcase = 0, count = 0;
        if(scan.hasNext())
            testcase = scan.nextInt();
        String[] rocks = new String[testcase];
        while(scan.hasNext()) {
            rocks[count] = removeDuplicateChar(scan.next());
            count++;
        }
        quickSort(rocks,0,rocks.length-1);
        String shortest = rocks[0];
        checkloop:
        for(int i = 1; i < testcase; i++ ){
            for(int j = 0; j < shortest.length(); j++){
                CharSequence cs = shortest.charAt(j)+"";
                if(!rocks[i].contains(cs)){
                    StringBuilder sb = new StringBuilder(shortest);
                    sb.deleteCharAt(j);
                    shortest = sb.toString();
                }
                if(shortest.length() == 0) {
                    break checkloop;
                }     
            }
        }
        System.out.println(shortest.length());
    }