local X = io.read()

local function main(str)
	local cloneStr = string.sub(str, 1, string.len(str) / 2)
	local s1 = string.gsub(cloneStr, "S", "")
	if string.len(s1) == 0 then
		print(0)
		return
	end

	str = string.gsub(str, "ST", "")

	local s = string.find(str, "ST")
	if s then
		return main(str)
	end
	print(string.len(str))
end

main(X)