# coding: utf-8
# Your code here!

X = list(input())
num = len(X)
stack = []

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