local X = io.read()

local function main(str)
	local sPos = string.find(str, "ST")
	if sPos then
		local ePos = sPos + 1
		local leftStr = string.sub(str, 1, sPos - 1)
		local rightStr = string.sub(str, ePos + 1, string.len(str))
		str = leftStr .. rightStr
		return main(str)
	end
	print(string.len(str))
end

main(X)