Hide

Problem CD
Deildajöfnuður

Languages en is

The dean of the university is organizing the finances of the university. The ministry of education provides financial support, according to a well defined government policy. The ministry finances the university by offering some number of grants. At the university there are $26$ departments, each labelled by an English letter. Each grant is dedicated to a specific department, which is decided by the ministry. All grants are equal in amount.

The dean can accept or reject each grant, but there are strict rules regarding this process. In order to limit the financial chaos for the ministry, the dean must select one contiguous sequence of grants to accept. The order of the grants is fixed and the dean is forbidden from shuffling them around. That means there can be no rejected grants between the earliest accepted grant and the latest accepted grant. Otherwise it would be too difficult for the ministry to plan its budget.

The dean wants to maximize the financial support the university receives. Ideally, he would like to accept all the grants. Sadly, his life is not so simple, since there is a requirement that all deparments which receive any funding must receive equal funding. This means that some departments may be completely unfunded. Some departments may even go completely unmentioned in the grants from the ministry.

Can you determine the highest number of grants the dean can accept and still fulfill these requirements?

Input

The first line of input contains one integer $n$, the number of grants, where $1 \leq n \leq 200$. The second line of input contains $n$ lowercase English letters, one for each grants, where each letter represents the department to which the grant is dedicated.

Output

Output one integer, the highest number of grants the dean can accept and still guarantee all funded departments receive equal funding.

Explanation of samples

In the first sample, the dean can accept all the grants, since each department that is listed in the input is listed exactly once.

In the second sample, the dean can accept the grants narnar, where each listed department appears twice. Note that department h, for example, even though it is listed in the input, receives no funding in this case, which is acceptable.

In the third sample, the dean can accept the grants arnanrnarnraranrna, where each listed department appears $6$ times.

Sample Input 1 Sample Output 1
4
fkhi
4
Sample Input 2 Sample Output 2
19
hannarnarkannthetta
6
Sample Input 3 Sample Output 3
20
zarnanrnarnraranrnax
18