X = input()
X = X.replace("ST","")
if X[:len(X) // 2].count("S") == len(X) // 2:
    print(0)
    exit()
for i in range(10**5):
    note = X
    X = X.replace("ST","")
    if note == X:
        break
print(len(X))