s = input()
a = s.count("a")
print(min(len(s), 2*a-1))
9f73aeb2e4b22e0f8875689c98669bf365930a23
<mask token>

<mask token>
print(min(len(s), 2 * a - 1))

s = input()
a = s.count('a')
print(min(len(s), 2 * a - 1))

s = input()
a = s.count("a")
print(min(len(s), 2*a-1))