There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.

Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginning of the line). In other words, if at some time the i-th position has a boy and the (i + 1)-th position has a girl, then in a second, the i-th position will have a girl and the (i + 1)-th one will have a boy.

Let's take an example of a line of four people: a boy, a boy, a girl, a girl (from the beginning to the end of the line). Next second the line will look like that: a boy, a girl, a boy, a girl. Next second it will be a girl, a boy, a girl, a boy. Next second it will be a girl, a girl, a boy, a boy. The line won't change any more.

Your task is: given the arrangement of the children in the line to determine the time needed to move all girls in front of boys (in the example above it takes 3 seconds). Baking buns takes a lot of time, so no one leaves the line until the line stops changing.


-----Input-----

The first line contains a sequence of letters without spaces s_1s_2... s_{n} (1 ≤ n ≤ 10^6), consisting of capital English letters M and F. If letter s_{i} equals M, that means that initially, the line had a boy on the i-th position. If letter s_{i} equals F, then initially the line had a girl on the i-th position.


-----Output-----

Print a single integer — the number of seconds needed to move all the girls in the line in front of the boys. If the line has only boys or only girls, print 0.


-----Examples-----
Input
MFM

Output
1

Input
MMFF

Output
3

Input
FFMMM

Output
0



-----Note-----

In the first test case the sequence of changes looks as follows: MFM  →  FMM.

The second test sample corresponds to the sample from the statement. The sequence of changes is: MMFF  →  MFMF  →  FMFM  →  FFMM.

Difficulty: interview

Starter code:

Solutions:
t = input()[:: -1]
i = t.find('F')
if i < 0: print(0)
else:
    j = t.find('M', i + 1)
    if j < 0: print(0)
    else:
        s, t = 0, t[j: t.rfind('M') + 1]
        for k in t:
            if k == 'M': s += 1
            else: s = max(s - 1, 0)
        print(s + t.count('F') + j - i - 1)

t = input()[:: -1]
i = t.find('F')
if i < 0:
     print(0)
else:
    j = t.find('M', i + 1)
    if j < 0:
        print(0)
    else:
        s, t = 0, t[j:t.rfind('M') + 1]
        for k in t:
            if k == 'M':
                s += 1
            else:
                s = max(s - 1, 0)
        print(s + t.count('F') + j - i - 1)

a=input();n=len(a);o,k=0,0
for i in range(n):
    if(a[i]=='F'):
        k=k+1
        if(i+1!=k):o=max(o+1,i+1-k)
print(o)

s = input()

f = 0
cur_t = -1
for i in range(len(s)):
    if s[i] == 'F':
        t = i - f
        f += 1
        if t > cur_t or t == 0:
            cur_t = t
        else:
            cur_t += 1

print(max(0, cur_t))
        
        


s = input()
n = len(s)
try:
    ai = s.index('M')
    bi = n - s[::-1].index('F')
    s = s[ai:bi]
    n = len(s)

    femcount = sum([1 if s == 'F' else 0 for s in s])

    cong = 0
    for a in s:
        if a == 'M':
            cong = max(0, cong - 1)
        else:
            cong += 1

    print(n - femcount + max(0, cong - 1))
except:
    print(0)

# while True:
#     l = list(s)
#     for i in range(len(s) - 1):
#         if s[i] == 'M' and s[i + 1] == 'F':
#             l[i] = 'F'
#             l[i + 1] = 'M'
#     if ''.join(l) == s:
#         break
#     s = ''.join(l)
#     print(s)


# https://codeforces.com/problemset/problem/353/D
s    = [0 if x=='M' else 1 for x in input()]
ans  =  0
pre  =  -1
num1 =  0

flg=False
for i in range(len(s)-1, -1, -1):
    if s[i]==1:
        flg=True
        num1+=1
    else:
        if flg==True:
            pre=pre+1
        ans=max(num1, pre)
        pre=ans
print(ans)        

s = input()
g,no,ans = 0,0,0
for i in range(len(s)):
	if(s[i] == 'M'):
		no = max(no-1,0)
	else:
		if(i != g):
			ans = max(ans,i-g+no)
			no += 1
		g += 1
print(ans)