Mirror IIOT 2022-2023, Final Round | base12

This was the problem page during the contest. Access the current page here.
Time limit: 0.4s
Memory limit: 128MB
Input:
Output:

Task

RANDy is now very interested in winning the grand prize at the new lotteries opened in his country. Because he has relations everywhere, he got a list of the winning numbers from all the NN lotteries available. The winning numbers are expressed in base 12 (the numbers can begin with digit 00).

However, the lotteries could not agree on which letters (upper case English alphabet letters) should be used for 1010 and 1111, so each made its own choice. Even though he has such a great advantage, RANDy still doesn't know the rules to win the lottery. He thinks that in order to win the prize from a lottery he needs to guess only one digit from the winning number.

He doesn't know how to write, so help him learn the minimum number of digits in order to win(in his conception) at each lottery.

Input

The first line of the input contains a single number, NN (1N2.51051 \le N \le 2.5*10^5), representing the number of lotteries. Each of the next NN lines contains a number written in base 12, representing the winning numbers.

The sum of lengths of all the numbers is at most 41064*10^6.

For test worth 1313 points, all the numbers will be written in base 1010.

For test worth 2121 more points, all numbers will be written in base 1212, but only with digits 1010 and 1111.

For test worth 2727 more points, 1N51031 \le N \le 5 * 10^3.

Output

The only line of the output contains a single integer, KK, representing the minimum number of digits RANDy has to learn how to write in order for him to believe he can win every lottery.

Example 1

stdin

4
AABAA
B112
DAA
1777768CD

stdout

2

Explanation

RANDy can learn the folowing two digits: 11 and AA. He can write "1""1" for lotteries 22 and 44 and "A""A" for lotteries 11 and 33. Thus he thinks that he wins at all of them.

Contest info

Official contest

Start time: 1677902400000

Total duration: 209h59m0s

Status: Ended

Individual duration: 3h0m0s

Log in or sign up to be able to send submissions!