X = list(input())

i = 0
check = 0

while check == 0 :
    if i == len(X) - 1 or i == len(X):
        check = 1
    else:
        #print(i, X)
        if X[i] == 'S' and X[i+1] == 'T':
            X.pop(i)
            X.pop(i)
            i = max(0, i-1)
        else:
            i += 1
        
    
print(len(X))
