Complexity

You delete the fewest letters so at most two distinct letters remain.

Easy3Hash mapGreedyInterviewNo attempts yetTime limit2sMemory limit256 MB

Problem

The complexity of a string is the number of distinct letters in it. For example, string has complexity 6 and letter has complexity 4.

You like strings whose complexity is 1 or 2. A friend handed you a string and you want to turn it into a string you like. You have a magic eraser that deletes one letter from the string. Compute the minimum number of times you have to use the eraser to make the complexity of the string at most 2.

Input

The first line contains a string made up of lowercase ASCII letters ('a' to 'z'). The length of the string is between 1 and 100.

Output

Print the minimum number of eraser uses on a single line.