fun main(arg: Array<String>) {
    var S = readLine()!!
    var L = S.length
    var M = mutableListOf<Char>()
    for (n in 0 until L) {
        M.add(S[n])
        if (M.size >= 2 && M[M.lastIndex - 1] == 'S' && M[M.lastIndex] == 'T') {
            M.removeAt(M.lastIndex) //remove 'T'
            M.removeAt(M.lastIndex) //remove 'S'
        }
    }
    println(M.size)
}
