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

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

main()