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

str = STDIN.gets.chomp
size = str.size

str1 = remove(str[0..size/2])
r_size = str1.size

str2 = str[size/2+1..-1]
if r_size > 0
  str2 = str1[-1] + str2
  r_size -= 1
end

str2 = remove(str2)
puts r_size+str2.size