X = input()

flag = True
while flag:
    flag = False
    i = 0
    while i < len(X):
        if X[i:i+2] == "ST":
            X = X[:i]+X[i+2:]
            flag = True
        else:
            i += 1

print(len(X))