X=input()
ans = len(X)
def chk(X,a,b):
    if a<0 or b>len(X)-1:
        return 0
    if X[a]=="S" and X[b]=='T':
        return chk(X,a-1,b+1)+2
    else:
        return 0
for i in range(len(X)-1):
    ans -= chk(X,i,i+1)
print(ans)