An obsessive artist has found a stain on the wall of his room. This stain is in the form…
- User
An obsessive artist has found a stain on the wall of his room. This stain is in the form of a long string n n is an English lowercase letter. The artist, who is very obsessive, wants to remove the stain as soon as possible. Because of his obsession, he only performs one of the following two operations to erase:
Change one letter from this string to another English letter. Select a consecutive palindrome substring of this string and delete it. A palindrome string is a string that can be read in the same way from both sides. Note that by deleting a substring, the two sides of that substring will stick together. For example, if the string represents the blob aabcx, the artist can remove the substring aa because it is a palindrome, and then change the last character to b to make the string bcb. Then, in another step, it can remove this palindrome string.
Unfortunately, the artist is too obsessed with the stain and asks you to calculate the minimum number of operations to remove it by taking the string representing the stain.
input In the single input line of the string S You will be given input from English lower case letter S which represents stain.
1 ≤ ∣ S ∣ ≤ 500 1≤∣S∣≤500
output In the single output line, print the minimum number of operations necessary to remove the stain.
examples Sample entry 1 abcba Plain text Sample output 1 1 Plain text In the example above, the string is palindrome from the beginning and it can be deleted in one step.
Sample entry 2 abcbx Plain text Sample output 2 2 Plain text In the above example, in the first step, the last letter can be changed to a, and then in the second step, the obtained palindrome string can be deleted.
Sample entry 3 aabcx Plain text Sample output 3 3 write in c++
- Assistant