题目描述
Alisha has a string of length n. Each character is either 'a', 'b' or 'c'. She has to select two characters s[i] and s[j] such that s[i] != s[j] and i,j are valid indexes. She has to find the maximum value of the absolute difference between i and j i.e abs(i-j) .
Since Alisha is busy with her Semester exams help her find the maximum distance where distance is the maximum value of absolute difference between i and j i.e abs(i-j) .
-----Input:-----
- The first and the only line contains the string s with each character either 'a', 'b', or 'c'.
-----Output:-----
Print a single integer the maximum absolute difference between i and j.
-----Constraints-----
- $1 \leq n \leq 10^5$
- s[i] can either be 'a', 'b' or 'c'.
-----Subtasks-----
- 40 points : $1 \leq n \leq 100$
- 60 points : $1 \leq n \leq 10^5$
-----Sample Input1:-----
aabcaaa
-----Sample Output1:-----
4
-----Sample Input2:-----
aba
-----Sample Output2:-----
1
输入格式
见题面
输出格式
见题面