s = [i for i in input()]
idx = 0
ans = len(s)
while idx < len(s) - 1:
    if s[idx] == "S" and s[idx+1] == "T":
        ans -= 2
        s.pop(idx)
        s.pop(idx)
        idx -= 1
    else:
        idx += 1
print(ans)