s = input()
n = len(s)
i = 0
t = 0
while i < n-1:
    if s[i] == "S" and s[i+1] == "T":
        s = s[:i] + s[i+2:]
        i = t+1
        n -= 2
    else:
        if s[i] == "T":
            t = i
        i += 1

print(n)
