#できなかった―　えーんえーん

X = input()

for i in range(10**10000):
    times = len(X) - 1 
    if times > 0:
        for j in range(times):
            if X[j] == "S" and X[j+1] == "T":
                newX = X[0:j]+X[j+2:len(X)]
                X = newX
    else:
        break

print(len(X))
    
        
            