X = input()

idx = 0

while idx < len(X):
    print(idx, X)
    if X[idx] == 'S':
        if idx+1 < len(X) and X[idx+1] == 'T':
            X = X[:idx] + X[idx+2:]
            idx = max(-1, idx-2)
    idx += 1

print(len(X))