x = input()
s = t = 0
for i in range(200000):
    if x[i] == "T":
        t += 1
    else:
        break
for i in range(200000):
    if x[-i-1] == "S":
        s += 1
    else:
        break
print(max(s, t) * 2)
