s=input()
c=1 if s[0] == 'S' else 0
ans=1 if s[0] == 'T' else 0

for i in range(1, len(s)):
    if s[i] == 'S':
        if s[i-1] == 'S':
            c += 1
        else:
            ans+=c
            c=1
    else:
        if c > 0:
            c -= 1
        else:
            ans += 1
print(ans+c)
