The Principality of Andorra was officially created in the year 1278 through an agreement between the Bishop of Urgell and the Count of Foix to have joint sovereignty of the territory, which lies along the border between France and Spain. Local traditions hold that the tiny country existed since the 9th century and that Charlemagne granted a charter to the Andorran people in return for fighting against the Moors. Over the centuries the tiny state (a census carried out in the 12th century found that 2298 people lived in Andorra) seemed it might have been annexed by one its larger neigbours, the country still remains with the same borders it had in 1278 – but it does pay an annual tribute of four hams, forty loaves of bread, and some wine to France and then to Spain in alternating years.