import numpy as np

X = input()

count = 0
while count < 10**10000:
    tmp = ""
    i = 0
    flag = 0
    while i < len(X)-1:
        if X[i]+X[i+1] == "ST":
            if i == len(X)-2:
                flag = 1
                break
            i += 2
        else:
            tmp += X[i]
            i += 1
    if flag == 0:
        if len(X)!=0:
            tmp += X[len(X)-1]

    if len(X)==len(tmp):
        break
    else:
        X = tmp
        count += 1
print(len(X))