ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

2060. Subpalindrome pairs

Time limit: 1.0 second
Memory limit: 64 MB
Your task is to calculate number of triplets (i, j, k) such that ij < k and s[i..j] is a palindrome and s[j+1 .. k] is a palindrome.

Input

The input contains a line of n lowercase Latin letters (1 ≤ n ≤ 3 · 105).

Output

Output the answer.

Sample

inputoutput
abaa
5
Problem Author: Mikhail Rubinchik
Problem Source: Palindromic Contest, July 11, 2015