import re

x = raw_input()

pattern = r'ST'

while(True):
    matchOB = re.search(pattern, x)
    if matchOB:
        y = x.split('ST')
        #print y
        x = ''.join(y)
    else:
        break

print len(x)
