parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	x = split(chomp(readline()),"")
	now = 1
	l = length(x)
	while l>0 && now < l
		if x[now] == "S" && x[now+1]=="T"
			deleteat!(x,now)
			deleteat!(x,now)
			l -= 2
			now = max(now-1, 1)
		else
			now += 1
		end
	end
	println(l)
end

main()