import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    counter = 0
    X = input().strip()
    stack = list()
    for s in X:
        if len(stack) < 1:
            stack.append(s)
        elif stack[-1] == "S" and s == "T" and counter < (10 ^ 10000) + 1:
            stack.pop()
            counter += 1
        else:
            stack.append(s)
    return len(stack)


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