x = list(input())
s = 0; t = 0
for i in range(len(x)):
    if x[i] == "T":
        t += 1
    else:
        break

for i in range(len(x)):
    if x[len(x)-i-1] == "S":
        s += 1
    else:
        break

print(s + t*2)
