def remove(s)                                                                                                                                                                                               
  return s.size unless i = s.index("ST")
  s[i, 2] = ""
  remove s
end

str = STDIN.gets.chomp
puts remove(str)