
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    var s=readLine()
    require(s!!.length %2 ==0 )
    var matched:Boolean
    val regex=Regex("ST")
    matched=regex.containsMatchIn(s)
    while(matched)
    {
      s=regex.replaceFirst(s!!,"")
      matched=regex.containsMatchIn(s)
    }
    print(s!!.length)
  }
}
