local n = io.read()

local function getABC(str)
	local result
	for i=#str, 2, -1 do
		local a = string.sub(str, i, i)
		if a == "T" then
			local b = string.sub(str, i-1, i-1)
			if b == "S" then
				result = #str - i
				break
			end
		end
	end

	if not result then
		result = #str
	end
	if result % 2 ~= 0 then
		result = result + 1
	end
	return result
end

local r = getABC(n)
print(r)