X = list(input())
while True:
    before = len(X)
    for i in range(len(X) - 1):
        if X[i] == "S" and X[i + 1] == "T":
            del X[i:i + 2]
            break
    if len(X) == before:
        break     
print(len(X))
