import streams, sequtils, strutils, algorithm, math, future, sets, tables, hashes
proc `ceilDiv`*[T](x, y: T): T = x div y + ord(x mod y != 0)
proc `//=`*(x: var SomeInteger; y: SomeInteger) = x = x div y
proc `%=`*(x: var SomeInteger; y: SomeInteger) = x = x mod y
var
    L = stdin.readLine
    ans:string
for i in 0..L.len-1:
    if L[i] == 'S':
        ans &= $L[i]
    else:
        if ans.len == 0 or ans[^1] == 'T':
            ans &= $L[i]
        else:
            ans = ans[0..^2]
echo ans.len
