import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val s = sc.next

  def loop(str: String): String ={
    val rep = str.replaceAll("ST", "")

    if(str.length == rep.length) str
    else loop(rep)
  }

  val res = loop(s).length

  println(res)

}
