x = gets.chomp.split('')
cur, nex = 0, 1
count = 0
while nex < x.length
  if x[cur] == 'S' && x[nex] == 'T'
    count += 1
    cur -= 1
    nex += 1
  else
    cur = nex
    nex += 1
  end
end
puts(x.length - count * 2)
