The accessory n. (or spinal accessory n.) is CN XI. The nerve originates from cervical spinal levels C1 through C6, ascends along the spinal cord, enters the cranial cavity through the foramen magnum, and then exits the cranial cavity through the jugular foramen (with CN IX and CN X). It provides motor innervation to the sternocleidomastoid and trapezius muscles.
From Wikipedia:
Traditional descriptions of the accessory nerve divide it into two parts: a spinal part and a cranial part. However, because the cranial component rapidly joins the vagus nerve, becoming an integral part of said nerve, modern descriptions often consider the cranial component to be part of the vagus nerve and not part of the accessory nerve proper. For this reason, in contemporary discussions of the accessory nerve, the common practice is to dismiss the cranial part altogether, referring to the accessory nerve specifically as the spinal accessory nerve