s = input()
prelength = len(s) + 1
length = len(s)
while prelength - length > 0:
    s = s.replace("ST", "")
    prelength = length
    length = len(s)
    #print(s, prelength, length)
    
print(len(s))