Two strings u1 u2 ... uk and v1 v2 ... vl are isomorphic if and only if k = l and there exists a injection g such that ui = g(vi) for all i ∈ {1, 2, ..., k}.
Note that a function f is injection if and only if f(x) ≠ f(y) for all x ≠ y.
Bobo would like to choose some strings from all n(n +1)/2 substrings of the given string s1 s2 ... sn.
Find out the maximum number of strings he may choose so that no two chosen strings are isomorphic.
输入描述:
The input consists of several test cases and is terminated by end-of-file.
The first line of each test case contains an integer n.
The second line contains a string s1, s2, ..., sn.
输出描述:
For each test case, print an integer which denotes the result.
备注:
* 1 ≤ n ≤ 5x 104
* si ∈ {a, b, c}
* The sum of n does not exceed 2 x 105.