X = input()
X = list(X)
prev = ""
for i in range(len(X) - 1):
    if X[i] + X[i + 1] == "ST":
        X.insert(0,X.pop(i))
        X.insert(1,X.pop(i+1))


for i in range(0, len(X)):
    if X[len(X) - (i+1)] == "T":
        print(i * 2)
        break