local str = io.read("*l")

local len = string.len(str)

local snum = 0
local tnum = 0
for i = 1,len do
	local j = string.sub(str,i,i)
	if j == "S" then
		snum = snum + 1
	elseif j == "T" then
		if snum > 0 then
			snum = snum - 1
		else
			tnum = tnum + 1
		end
	end
end
local ret = snum + tnum
print(ret)