# coding: utf-8
# Your code here!

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

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