stL = list(input())

flag=1
beforeC=""
while flag:
    flag=0
    index=0
    while index < len(stL):
        if index==0:
            beforeC = stL[index]
        else:
            if beforeC=="S" and stL[index]=="T":
                del stL[index-1]
                del stL[index-1]
                flag=1
                break
            else:
                beforeC = stL[index]
        index+=1
print(len(stL))