X = input()
Index = 0
for j in range(pow(10,10000)):
    if len(X) <= Index + 1 :
        break
    else:
        if X.find('ST',Index,Index+2) >= 0:
            if Index > 0:
                X = X[0:Index] + X[Index + 2:len(X)]
                Index -= 1
                continue
            else:
                X =  X[Index + 2:len(X)]
                continue
    Index +=1
print(len(X))