STREDUCE - String reduction

no tags 

Given a string containing only characters of 'a' and 'b'. You can reduce this string by replacing a substring forming a?a or b?b by ?; ? is 'a' or 'b'.

Request

Find a way to minimize the length of given string by reducing it. Output that minimum length.

Input

- A string.

Output

- The minimum length found.

Example

Input:
baaba

Output:
1

Limitations

- The length of the given string does not exceed 300.


hide comments
gawry: 2009-08-20 10:59:49

The input seems to contain some strange white characters, do not use gets.

Seckin Can Sahin: 2009-08-20 10:59:49

in the example,
baaba -> bab -> a

(aba -> b, and then bab ->a)

ahmed mamdouh [devils13]: 2009-08-20 10:59:49

what is the meaning of
"a?a or b?b by ?; ? is 'a' or 'b'" ?

Re: it means you have 4 operator:
aaa>>a
aba>>b
bab>>a
bbb>>b

ok ;)

Last edit: 2009-07-12 03:29:14
Carlos Eduardo Rodrigues Alves [USJT]: 2009-08-20 10:59:49

Only one string in the input.

Last edit: 2009-06-28 04:03:56
Karpovych Artem: 2009-08-20 10:59:49

what input should be in this problem?
Only one string?


Added by:AnhDQ
Date:2009-06-26
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:NEERC 2001 - Western Subregion