if __name__=='__main__':
    st = input()
    i = 0
    j = i+1
    ans = 0
    while j<len(st):
        #print("aa")
        if st[i]=='S' and st[j]=='T':
            #print("haha-> ",i,j)
            ans+=1
            if i==0:
                i=j+1
                j+=2
            else:
                i-=1
                j+=1
        else:
            i+=1
            j+=1
    print(len(st)-(ans*2))
        
