X = eval(input())



A = ""

for x in X:

    if x == "T" and A != "" and A[-1] == "S":

        A = A[:-1]

    else:

        A = A + x



print((len(A)))

from collections import deque

X = eval(input())

L = deque([])

for e in X:

    if e == "T" and len(L) > 0 and L[-1] == "S":

        L.pop()

    else:

        L.append(e)



print((len(L)))

X = eval(input())
A = ""
for x in X:
    if x == "T" and A != "" and A[-1] == "S":
        A = A[:-1]
    else:
        A = A + x
print((len(A)))

from collections import deque

X = eval(input())
L = deque([])
for e in X:
    if e == "T" and len(L) > 0 and L[-1] == "S":
        L.pop()
    else:
        L.append(e)
print((len(L)))

+from collections import deque + -A = "" -for x in X: -    if x == "T" and A != "" and A[-1] == "S": -        A = A[:-1] +L = deque([]) +for e in X: +    if e == "T" and len(L) > 0 and L[-1] == "S": +        L.pop() -        A = A + x -print((len(A))) +        L.append(e) +print((len(L)))