x=gets.chomp.split("")

i=0
while(i < x.size - 1)
    if(x[i] == 'S' and x[i+1] == 'T')
        x.delete_at(i)
        x.delete_at(i)
        i -= 1 if i > 0
    else
        i += 1
    end
end

puts x.size