x = str(input())
n = len(x)
stack = []
for i in range(n):
    if x[i] == 'S':
        stack.append('S')
    elif x[i] == 'T' and (len(stack) == 0 or stack[len(stack) - 1]) == 'T':
        stack.append('T')
    elif x[i] == 'T' and stack[len(stack) - 1] == 'S':
        stack.pop()
print(len(stack))
