x=input()
n=len(x)
cs=0
ct=0
if n>200:
    for i in range(n):
        if x[i]=="S":
            n-=min(cs,ct)*2
            ct=0
            cs+=1
        else:
            ct+=1
    n-=min(cs,ct)*2
    print(n)
else:
    while True:
        x=x.replace("ST","")
        if n==len(x):
            break
        else:
            n=len(x)
    print(n)