#AGC005
s = input()
nost = False
while not nost:
    if len(s) == 0:
        nost = True
    else:
        prev = s[0]
        for i in range(1, len(s)):
            nost = True
            if prev == 'S' and s[i] == 'T':
                nost = False
                s = s[:i-1] + s[i+1:]
                break
            prev = s[i]
        
print(len(s))
        
        