The Mayan calendar is proposed to derive from an arithmetical model of naked-eye astronomy. The Palenque and Copan lunar equations, used during the Maya Classic period (200 to 900 AD) are solution of the model and the results are expressed as a function of the Xultun numbers, four enigmatic Long Count numbers deciphered in the Maya ruins of Xultun, dating from the IX century AD, providing strong arguments in favor of the use of the model by the Maya. The different Mayan Calendar cycles can be derived from this model and the position of the Calendar Round at the mythical date of creation 13(0).0.0.0.0 4 Ahau 8 Cumku is calculated. This study shows the high proficiency of Mayan mathematics as applied to astronomy and timekeeping for divinatory purposes. a arXiv:1601.03132v7 [math.HO]