fun main(arg: Array<String>) {
    var S = next()
    var L = S.length
    var M = mutableListOf<Char>()
    var n = 0
    var c=0
    while (n < L) {
        M.add(S[n++])
        if (M.size >= 2 && M[M.lastIndex-1] == 'S' && M[M.lastIndex] == 'T') {
             M.removeAt(M.lastIndex)
             M.removeAt(M.lastIndex)
            c++
}
}
    println(L - (2 * c))
}
fun next() = readLine()!!