X = input().strip()



stack = []

for c in X:

    if c == 'S':

        stack.append(c)

    else:

        if len(stack) == 0 or stack[-1] == 'T':

            stack.append(c)

        else:

            stack.pop()

print((len(stack)))
def a_st_ring():

    X = eval(input())

    stack = []

    for c in X:

        if len(stack) > 0 and stack[-1] == 'S' and c == 'T':

            stack.pop()

        else:

            stack.append(c)

    return len(stack)



print((a_st_ring()))
X = input().strip()
stack = []
for c in X:
    if c == "S":
        stack.append(c)
    else:
        if len(stack) == 0 or stack[-1] == "T":
            stack.append(c)
        else:
            stack.pop()
print((len(stack)))

def a_st_ring():
    X = eval(input())
    stack = []
    for c in X:
        if len(stack) > 0 and stack[-1] == "S" and c == "T":
            stack.pop()
        else:
            stack.append(c)
    return len(stack)


print((a_st_ring()))

-X = input().strip() -stack = [] -for c in X: -    if c == "S": -        stack.append(c) -    else: -        if len(stack) == 0 or stack[-1] == "T": +def a_st_ring(): +    X = eval(input()) +    stack = [] +    for c in X: +        if len(stack) > 0 and stack[-1] == "S" and c == "T": +            stack.pop() +        else: -        else: -            stack.pop() -print((len(stack))) +    return len(stack) + + +print((a_st_ring()))