X=list(input())

f=True

while f and X:
    for i in range(len(X)-1):
        print(X) #DB
        if X[i:i+2]==['S','T']:
            del X[i:i+2]
            print (X) #DB
            break
        if i==len(X)-2:
            f=False

print(len(X))