Palindrome Partitioning#11245

Palindrome Partitioning

2 seconds
128 megabytes
Medium

A string partition is called a palindromic partition if every substring in this partition is a palindrome. For example, the string "ababbbabbababa" can be partitioned as "aba|b|bbabb|a|b|aba" — this is an example of a palindromic partition.

Determine the minimum number of cuts required for the palindromic partitioning of a given string. For example:

Input

One string of length no more than .

Output

Print the minimum number of cuts needed for the palindromic partitioning of the string .

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading