시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB111100.000%

문제

Grammy had a unique insight about strings. She thinks that a string is positive if and only if it is lexicographically larger than its reversal.

Now you are given a string, please find out how many contiguous substrings of it are positive according to Grammy's insight.

입력

The single line contains a string $S$ ($1 \leq |S| \leq 200\,000$), consisting of lowercase English letters only.

출력

Output a single integer denoting the number of positive substrings of $S$.

예제 입력 1

jjikkollp

예제 출력 1

4

예제 입력 2

pbpbppb

예제 출력 2

7