from sys import stdin
from itertools import groupby

s = stdin.readline().rstrip()
S = len(s)

start = 0
goal = S-1

for i,j in enumerate(s):
    if j == "S":
        start = i
        break
for i,j in enumerate(s[::-1]):
    if j == "T":
        goal = S-i
        break

s = s[start:goal]
print(S-min(s.count("T"),s.count("S"))*2)