s = input()
n = len(s)

while s != "":
    for i in range(n):
        if i == n-1:
            print(n)
            exit()
        if s[i]+s[i+1] == "ST":
            s = s[:i] + s[i+2:]
            n = len(s)
            break

print(0)