fun main(args: Array<String>){
    val x = readLine()!!
    var ans = 0
    var sCnt = 0
    x.forEach {
        if (it == 'S') sCnt++ else if (sCnt == 0) ans++ else sCnt--
    }
    println(ans * 2)
}
