msg=input()
lwbd=0
for lwbd in range(len(msg)):
    if msg[lwbd]=='S':
        break
upbd=len(msg)
for upbd in range(len(msg)-1,-1,-1):
    if msg[upbd]=='T':
        break

xs=msg[lwbd:upbd+1].count('S')
xt=msg[lwbd:upbd+1].count('T')

print(len(msg)-min(xs,xt)*2)
