string = input()
stack = ""

for i in string:
    if i == "S":
        stack += i
    elif i == "T" and (stack == "" or stack[-1] == "T"):
        stack += i
    else:
        stack = stack[0:-1]
    print(stack)

print(len(stack))
