X = input()

i = 0
while i < len(X):
    # print(i)
    while i + 1 < len(X) and X[i:i+2] != 'ST':
        i += 1

    if i + 1 >= len(X):
        break
    X = X[:i] + X[i+2:]
    i -= 1

print(len(X))
