package main
import (
  "fmt"
  "strings"
)
func main() {
  var s,t string
  fmt.Scan(&s)
  for {
    t = s
    s = strings.Replace(s,"SSSTTT","",-1)
    s = strings.Replace(s,"SSTT","",-1)
    s = strings.Replace(s,"ST","",-1)
    if s == t { break }
  }
  fmt.Println(len(s))
}