def main():
    S = input()
    stack = []
    for i in range(len(S)):
        stack.append(S[i])
        while len(stack) > 1 and "".join(stack[-2:]) == "ST":
            stack.pop()
            stack.pop()
        print(stack)
    return len(stack)


if __name__ == '__main__':
    print(main())