You are given a string a-z
.
Let us define an RSP (Reverse Substring Partition) as an operation where you partition
In order to perform an RSP, it is required that during the final step, the last letter of the leftmost partition is the same as the first letter of the rightmost partition so they can be merged. Otherwise, this operation cannot be performed. More formally, you may perform an RSP by partitioning
After performing any number of RSPs, what is the minimum possible length of
Constraints
Input Specification
The first line of input contains an integer
The next line of input contains
Output Specification
Output a single integer, the smallest possible resulting length of
Sample Input
4
noon
Sample Output
2
Comments