X = input()
n = len(X)
num1 = 0
while True:
    if X[num1] == "T":
        num1 += 1
    else:
        break


num2 = 0
while True:
    if X[n-1-num2] == "S":
        num2 += 1
    else:
        break


print(max(num1,num2)*2)