fun main(args: Array<String>) {
    agc005a()
}

fun agc005a() {
    var x = readLine()!!

    var beforeLength = -1
    while (beforeLength != x.length) {
        beforeLength = x.length
        x = x.replace("ST", "")
    }

    println(x.length)
}
