import sys

from collections import deque



X = list(sys.stdin.readline().strip())



s = []

q = deque(X)

while q:

    char = q.popleft()

    if len(s) == 0:

        s.append(char)

        continue

        

    if char == "T" and s[-1] == "S":

        s.pop()



    else:

        s.append(char)



print((len(s)))
import sys



X = sys.stdin.readline().strip()

lx = len(X)



stack = []

pop_n = 0

for c in X:

    if c == "S":

        stack.append(c)

    elif c == "T" and 0 < len(stack):

        stack.pop()

        pop_n += 1



print((lx - 2 * pop_n))
import sys
from collections import deque

X = list(sys.stdin.readline().strip())
s = []
q = deque(X)
while q:
    char = q.popleft()
    if len(s) == 0:
        s.append(char)
        continue
    if char == "T" and s[-1] == "S":
        s.pop()
    else:
        s.append(char)
print((len(s)))

import sys

X = sys.stdin.readline().strip()
lx = len(X)
stack = []
pop_n = 0
for c in X:
    if c == "S":
        stack.append(c)
    elif c == "T" and 0 < len(stack):
        stack.pop()
        pop_n += 1
print((lx - 2 * pop_n))

-from collections import deque -X = list(sys.stdin.readline().strip()) -s = [] -q = deque(X) -while q: -    char = q.popleft() -    if len(s) == 0: -        s.append(char) -        continue -    if char == "T" and s[-1] == "S": -        s.pop() -    else: -        s.append(char) -print((len(s))) +X = sys.stdin.readline().strip() +lx = len(X) +stack = [] +pop_n = 0 +for c in X: +    if c == "S": +        stack.append(c) +    elif c == "T" and 0 < len(stack): +        stack.pop() +        pop_n += 1 +print((lx - 2 * pop_n))