def Greedy(X):
    L=[0]
    while L:
        L=[]
        for i in range(len(X)):
            if X[i:i+2]=="ST":
                L.append(i)

        for i in L[::-1]:
            X=X[:i]+X[i+2:]

    return len(X)

X=input()
print(Greedy(X))