import sys
s = sys.stdin.readline().strip()                                                                                                                                                                                                      

i = 0
while i < len(s)-1:
        if s[i] == 'S' and s[i+1] == 'T':
                s = s[:i] + s[i+2:]
                if i > 0:
                        i -= 1
        else:   
                i += 1

print len(s)