fun main(args: Array<String>) {
    var s = 0
    var ans = 0
    var len = 0
    for (c in readLine()!!) {
        len++
        if (c == 'S') s++ else {
            if (s > 0) { ans++; s-- }
        }
    }
    println(len - 2 * ans)
}