Maximum Number Of Characters Between Any Two Same Characters

easy
1.Given a string containing lower and uppercase alphabets 2.The task is to find the maximum number of characters between any two same character in the string. 3.You have to complete the function printMax() to print the maximum number. If no character repeats, print "-1".

Input Format

Single line containing String S

Output Format

Print the maximum number in new line. If no character repeats, print "-1".

Constraints

1<=|string length|<=10^5

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
socks
Output
3
Previous
Maximum Distinct Elements After Removing K Elements
Next
Maximum Possible Sum

Related Questions