X = gets.chomp

chars = Array.new(X.size) {0}
stack = []

X.chars.each_with_index do |s, i|
  if s == 'S'
    stack << i
  else
    next if stack.empty?
    si = stack.pop
    chars[si] = -1
    chars[i] = -1
  end
end

res = ''
X.chars.each_with_index do |s, i|
  if chars[i] == 0
    res += s
  end
end

puts res.size
