local n = io.read()

local function getABC(str)

	local result = 0
	local function getStr(ss)
		local p = string.find(ss, "ST")
		if not p then
			result = #ss
			return
		end
		local s1 = string.sub(ss, 1, p-1)
		local s2 = string.sub(ss, p+2, #ss)
		local s = s1 .. s2
		getStr(s)
	end
	getStr(str)


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

local r = getABC(n)
print(r)