import copy
X = input()
X = list(X)
prev = ""
while(1):
    prev = copy.copy(X)
    for i in range(len(X) - 1):
        if X[i]+X[i + 1] == "ST":
            X.pop(i+1)
            X.pop(i)
            break
    if prev == X:
        break
print(len(X))