parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	s = readline() |> chomp
	n = length(s)
	l = 0
	r = 0
	for i in 1:n
		if s[i]=='S'
			l = i-1
			break
		end
	end
	for i in n:-1:1
		if s[i]=='T'
			r = n-i
			break
		end
	end	
	println(max(l,r)*2)
end

main()