x = gets.to_s.chomp.split("")
#p x
count = 0
while count < 10 ** 1000 do
	del_flg = 0
	(x.length - 1).times do |i|
		if x[i] == "S" && x[i + 1] == "T"
			x.delete_at(i)
			x.delete_at(i)
			del_flg = 1
		end
	end
	if del_flg == 0
		puts x.length
		#p x
		break 
	end
end
