LearnPy Hub
← Arena
AdvancedRating 1800

Count Palindromic Subsequences

Count the non-empty subsequences (chosen by positions) that are palindromes, modulo 1 000 000 007.

Input

One string (length ≤ 1000).

Output

One integer.

Sample 1

Input
aab
Output
4

Sample 2

Input
abcd
Output
4
solution.py
Output appears here
Count Palindromic Subsequences · Python Arena problem · LearnPy Hub