Consider n pieces of rope. Each piece is colored blue

Consider n pieces of rope. Each piece is colored blue at one end and red at the other. The blue ends of the ropes are randomly paired with the red ends of the ropes and tied together, one-to-one, i.e., all n! Such possible methods of joining the ropes this way are equally likely. Let X be the number of loops that result from this method. Find E(X).