X = list(input())

delete = True
while delete:
    delete = False
    for i in range(len(X)-1):
        if X[i] == 'S' and X[i+1] == 'T':
            delete = True
            del X[i:i+2]
            break
print(len(X))