s=raw_input()
while True:
    f=0
    for i in xrange(len(s)-1):
        if s[i]=="S" and s[i+1]=="T":
            s=s[0:i]+s[i+2:len(s)]
            f=1
            break
    if f==0:
        break
print(len(s))