from sys import stdin
X = (stdin.readline().rstrip())
stack = []
for i in X:
    if i == "S":
        stack.append(i)
    elif i == "T" and stack[-1] == "S":
        stack.pop()
    else:
        stack.append(i)
print(len(stack))