S = input()
lenS = len(S)
index = 0
ans = lenS
while index < lenS-1:
    if S[index:index+2] == "ST":
        S = S[:index] + S[index+2:]
        ans -= 2
        index -= 1
    else:
        index += 1
print(str(ans))