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

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