#P7079. Good Contest Problem Selection

    ID: 20285 Type: Default 1000ms 256MiB

Good Contest Problem Selection

Good Contest Problem Selection

Little Dmitry and little Petr want to arrange a contest. Their little friends submitted several task proposals and now Dmitry and Petr want to select some of them for the contest. As they are just little boys, they cannot estimate the quality of tasks, but they know for sure that in a good contest, the title of the first problem starts with A, the title of the second one starts with \(B\), and so on.

Given the titles of the proposed tasks, determine the maximal number of problems in a good contest that they can arrange.

inputFormat

The first line contains a single integer \(n\) (\(1 \le n \le 100\)), representing the number of proposed tasks. Each of the next \(n\) lines contains a non-empty string representing the title of a proposed task. All titles consist of uppercase English letters.

outputFormat

Output a single integer representing the maximal number of problems that can be arranged in a good contest. In other words, find the largest integer \(k\) such that for every \(i\) from \(0\) to \(k-1\), there is at least one task whose title starts with the letter \(\text{chr}(\text{ord}('A')+i)\).

sample

6
APPLE
BOOK
CAT
DOG
AXE
BEE
4