x = raw_input()
stack = []
ans = 0
for i in xrange(len(x)):
    if x[i] == "S":
        stack.append("S")
    else:
        if len(stack) == 0:
            ans += 1
        else:
            stack.pop()
print ans + len(stack)
