x = input()

t = 0
s = 0
for i in x:
    if i == "T":
        t += 1
    else:
        break
for j in x[::-1]:
    if j == "S":
        s += 1
    else:
        break

b = x[t:-s]
print(t + s + abs(b.count("S") - b.count("T")))