import sys
X = sys.stdin.readline()
cnt = 10**10000
while cnt > 0:
    a = X.split("ST",min(0x7fffffff,cnt))
    if(len(a) == 1):
        break
    cnt -= len(a) - 1
    X = "".join(a)

print(len(X)-1)