a = gets.chomp.split("")#.map(&:to_i)

k1 = a.take_while{|s| s == "T"}
k2 = a.reverse.take_while{|s| s == "S"}

if k1.size > k2.size
  #puts "T"*k1.size + "S"*k1.size
p k1.size*2
else
  #puts "T"*k2.size + "S"*k2.size
p k2.size*2
end
