s = input()

sc = 0
tc = 0
ans = len(s)
for si in s:
    if si == "S":
        sc += 1
    else:
        tc += 1
        if sc:
            ans -= min(sc,tc)*2
            sc -= min(sc,tc)
            tc -= min(sc,tc)
        #print(ans,sc,tc)
print(ans)