def main(argv)
  s = STDIN.gets.chomp
  n = s.size
  
  while true do
    s.gsub!(/ST/, '')
    
    if s.size == n then
      break
    end
    
    n = s.size
  end
  
  STDOUT.puts s.size.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end