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

Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-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?

Input

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

Output

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

Examples

Input

abba


Output

4

Input

bab


Output

2

Note

It the first sample the string is already beautiful.

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

Solution (in PYTHON3):

Solution:
 ######      ###      #######    #######    ##      #     #####        ###     ##### 
 #     #    #   #          #        #       # #     #    #     #      #   #     ###  
 #     #   #     #        #         #       #  #    #   #       #    #     #    ###  
 ######   #########      #          #       #   #   #   #           #########    #   
 ######   #########     #           #       #    #  #   #           #########    #   
 #     #  #       #    #            #       #     # #   #    ####   #       #    #   
 #     #  #       #   #             #       #      ##   #    #  #   #       #        
 ######   #       #  #######     #######    #       #    #####  #   #       #    #   

# from __future__ import print_function # for PyPy2
from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
from math import *

g   = lambda : stdin.readline().strip()
gl  = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1e9)+7
inf = float("inf")                      

s = "*"+g()
n = len(s)-1
a, b = [0]*(n+2), [0]*(n+2)
a_, b_ = [0]*(n+2), [0]*(n+2)
for i in range(1, n+1):
	(a if s[i] == "a" else b)[i] += 1
	a[i] += a[i-1]
	b[i] += b[i-1]

for i in reversed(range(1, n+1)):
	(a_ if s[i] == "a" else b_)[i] += 1
	a_[i] += a_[i+1]
	b_[i] += b_[i+1]

ans = max(a[-1], b[-1])


for i in range(1, n+1):
	ans = max(ans, a[i]+b_[i+1], b[i]+a_[i+1])

for l in range(2, n-1):
	for r in range(l, n):
		ans_ = a_[r+1]+a[l-1] + b[r] - b[l-1]
		ans = max(ans, ans_)

print(ans)