For an Instagram reel of icpc_umss, the team wants to bake letter-shaped cookies and use them to spell several words. Each word is prepared in one batch: all of its letters are baked at the same time, using one mold per cookie.
Each mold has a fixed letter and can be reused, but it must cool down for one full batch after each use. For example, a mold used in the first batch cannot be used in the second one, but it can be used in the third.
The words must be prepared in the given order, with no additional pauses or empty batches. At the beginning, all molds are cold. What is the minimum total number of molds that must be bought before starting?
The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 1000$$$), the number of words.
Each of the following $$$N$$$ lines contains a word $$$S_i$$$ of between $$$1$$$ and $$$1000$$$ uppercase letters of the English alphabet (A to Z). Repeated letters require different molds within the same batch.
Print an integer: the minimum total number of molds needed.
3ANALIAANA
6
1ICPC
4
Explanation for example 1
Three A molds, one N, one L and one I are bought. The first batch uses two A molds and the N mold; the second uses the third A mold, the L mold and the I mold. By the third batch the molds from the first batch are already cold, so the two A molds and the N mold can be reused.
Explanation for example 2
Two C molds, one I and one P are needed: the word ICPC uses the letter C twice in the same batch, so two different molds of that letter are required.
| Название |
|---|


