In the last ACM training, Dima learned about palindromic strings, strings that read the same way when they're reversed (e.g. AABAA). Excited about what she learned, Dima decided to give her friend Rund a challenge:
Let's define an operation as increasing or decreasing a letter of a string (for example, in 1 operation, AAB can be turned into AAC or AAA).
Given a string, what's the minimum number of operations that can be applied to the string, such that every possible substring of that string is a palindrome?
Since Rund is not very good at handling strings, she asked you to help her as Dima is going to treat her to mansaf if she solves the challenge.
Note that a substring is a contiguous sequence of characters within a string. For instance, "MAN" and "AF" are substrings of the string "MANSAF", while "MF and "AS" are not.