import copy
x = str(input())
MAX = pow(10, 10000)
for i in range(MAX):
    try:
        prev_x = copy.deepcopy(x)
        x = "".join(x.split("ST"))
        if x == prev_x:
            break
    except ValueError:
        break
print(len(x))
