S = input()
scount = 0
tcount = 0
ans = 0
for c in S:
    if c == "S":
        ans += min(scount, tcount) * 2
        tcount = 0
        scount += 1
    else:
        tcount += 1

ans += min (scount,tcount) * 2
ans = len(S) -ans
print(ans)