X = input()

while True:
    length = len(X)
    isST = True
    for i in range(length-1):
        if X[i] == "S" and X[i+1] == "T":
            X = X[:i] + X[i+1+1:]
            break
        else:
            continue
        
    if "ST" not in X:
        break
        
    

print(len(X))