public static void GemStone(String[] args) { //change name for main
        Scanner in = new Scanner(System.in);
        int numberOfTests = in.nextInt();
        String[] tests = new String[numberOfTests];

        for(int i = 0; i < numberOfTests; i++)
        {
            tests[i] = in.next();
        }

        RedBlackTree mainTree = new RedBlackTree();
        StringBuilder builder = new StringBuilder();
        for(int i=0; i < tests[0].length();i++)
        {
            if(!mainTree.find(tests[0].charAt(i)))
            {
                mainTree.add(tests[0].charAt(i));
                builder.append(tests[0].charAt(i));
            }
        }

        String mainString = builder.toString();

        RedBlackTree[] trees = new RedBlackTree[numberOfTests-1];
        for(int j=1; j< numberOfTests;j++)
        {
            trees[j-1] = new RedBlackTree();
            for(int k=0; k < tests[j].length(); k++)
            {
                trees[j-1].add(tests[j].charAt(k));

            }
        }
        int conteo = 0;
        for(int i=0; i < mainString.length();i++)
        {
            int contadorSecundario = 0;
            for(int j=0; j < trees.length; j++)
            {
                if(trees[j].find(mainString.charAt(i)))
                {
                    contadorSecundario++;
                }
            }
            if(contadorSecundario == numberOfTests-1)
            {
                conteo++;
            }
        }
        System.out.println(conteo);
    }