Love "A"

题意翻译

## 题目描述 Alice有一个字符串。她很喜欢字母'a'。如果这个字符串中有一半以上(不包括一半)的字母是'a',那么她就把这个字符串称为'good'。例如"aaabb"、"axaa"就是'good',而"baca"、"awwwa"、空字符串则不是。Alice可以从字符串s中删除一些字母。她想知道在删除一些字母(可能是0)后,这个成为'good'的字符串的最长长度是多少。保证字符串中至少有一个'a'。 ## 输入格式 第一行是一个用小写英文字母构成的字符串s(1<=|s|<=50)。保证s中至少有一个'a'。 ## 输出格式 输出一个整数,它是Alice从s中删除一些字符后,可以得到的最长的'good'的长度。 ## 提示 在第一个样例中,我们可以删除4个'x',剩下2个'a'和1个'x',所以答案是3。 在第二个样例中,我们不需要删除字母,所以答案是6。

题目描述

Alice has a string $ s $ . She really likes the letter "a". She calls a string good if strictly more than half of the characters in that string are "a"s. For example "aaabb", "axaa" are good strings, and "baca", "awwwa", "" (empty string) are not. Alice can erase some characters from her string $ s $ . She would like to know what is the longest string remaining after erasing some characters (possibly zero) to get a good string. It is guaranteed that the string has at least one "a" in it, so the answer always exists.

输入输出格式

输入格式


The first line contains a string $ s $ ( $ 1 \leq |s| \leq 50 $ ) consisting of lowercase English letters. It is guaranteed that there is at least one "a" in $ s $ .

输出格式


Print a single integer, the length of the longest good string that Alice can get after erasing some characters from $ s $ .

输入输出样例

输入样例 #1

xaxxxxa

输出样例 #1

3

输入样例 #2

aaabaa

输出样例 #2

6

说明

In the first example, it's enough to erase any four of the "x"s. The answer is $ 3 $ since that is the maximum number of characters that can remain. In the second example, we don't need to erase any characters.