fun main(args: Array<String>) {
    val s = readLine()!!
    var countS = 0
    var countT = 0
    val halfLength = s.length / 2
    for (c in s) {
        if (c == 'S') {
            countS++
        } else {
            countT++
        }
        if (countT == halfLength) {
            println(s.length - (countS * 2))
            break
        }
    }
}