local sub = string.sub
s = io.read()

local function solve()
	local n = 0
	local left = 0
	for i = 1, #s do
		local c = sub(s, i, i)
		if c == "S" then
			left = left + 1
		elseif left > 0 then
			left = left - 1
			n = n + 2
		end
	end
	return #s - n
end
print(solve())