fun main(arg: Array<String>) {
    var S = next()
    var L = S.length
    while (true) {
         val l = L
        S= S.replace("ST", "")
        L = S.length
        if (l == L) break
    }
    println(S.length)
}
fun next() = readLine()!!