STREDUCE - String reduction

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.


Được gửi lên bởi:AnhDQ
Ngày:2009-06-26
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:NEERC 2001 - Western Subregion

hide comments
2018-08-19 13:09:33
B(a ^ 8)*1.
qc + osf ^^
qvau gehbat ynz.
2009-06-27 11:34:20 Nguyễn Xuân Khánh
Xâu 'aa' có thể chuyển thành xâu rỗng được không ?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.