import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    X = input().strip()
    while X.count("ST"):
        a = X.find("ST")
        X = X[:a] + X[a + 2:]

    print(len(X))


if __name__ == '__main__':
    main()
