X=input()
flg = True
while flg and len(X):
    flg = False
    for i in range(len(X)-1):
        if X[i]=='S' and X[i+1] =='T':
            if i<len(X)-1:
                X=X[:i]+X[i+2:]
            else:
                X=X[:i]
            flg = True
            break
print(len(X))