# cook your code here
from sys import stdin
a = stdin.readline().strip()
l = len(a)
s = 0
t = 0
i = l-1
while i>=0:
    if a[i]=='T':
        t+=1 
    else:
        if t>0:
            t-=1 
        else:
            s+=1
    i-=1 
print s+t            