CF877B.Nikita and string

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

One day Nikita found the string containing letters "a" and "b" only.

Nikita thinks that string is beautiful if it can be cut into 33 strings (possibly empty) without changing the order of the letters, where the 11 -st and the 33 -rd one contain only letters "a" and the 22 -nd contains only letters "b".

Nikita wants to make the string beautiful by removing some (possibly none) of its characters, but without changing their order. What is the maximum length of the string he can get?

输入格式

The first line contains a non-empty string of length not greater than 50005000 containing only lowercase English letters "a" and "b".

输出格式

Print a single integer — the maximum possible size of beautiful string Nikita can get.

输入输出样例

  • 输入#1

    abba
    

    输出#1

    4
  • 输入#2

    bab
    

    输出#2

    2

说明/提示

It the first sample the string is already beautiful.

In the second sample he needs to delete one of "b" to make it beautiful.

首页