~/algor $ cat problems/dp-palindromlarga-bolish
Palindrome partitioning
Medium
1000 ms
128 MB
62%
A string $s$ of lowercase Latin letters is given. It must be split into consecutive pieces so that every piece is a palindrome (reads the same from left to right and from right to left). What is the smallest number of pieces needed? For example, abaccd can be split into three pieces: aba, cc, d.
Input
One line with the string $s$.
Output
One integer — the smallest number of pieces.
Note
$1 \le |s| \le 1000$
$s$ consists only of lowercase Latin letters
Examples
Input #1
abaccd
Output #1
3
Input #2
aab
Output #2
2