fun main() {
    val x = readLine() ?: return
    var r = 0
    var sC = 0
    x.forEach {
        when (it) {
            'S' -> {
                sC++
            }
            'T' -> {
                if (sC > 0) {
                    sC--
                    r += 2
                }
            }
        }
    }
    println((x.length - r).toString())
}
