The Eleventh Doctor was the final incarnation in the Doctor's first cycle of regenerations. By the time he was in that incarnation, he had regenerated 12 times (the maximum). However, one incarnation (usually called the "War Doctor") didn't use the name Doctor & therefore isn't counted in the First Doctor, Second Doctor, Third Doctor, &c numbering. The "War Doctor" was the incarnation between the Eighth Doctor & the Ninth (see "The Night of the Doctor" & "The Day of the Doctor"). Additionally, in "The Stolen Earth"/"Journey's End", the Tenth Doctor regenerated without changing into a new incarnation (or changed into an identical incarnation, whichever way you want to look at it) & continued to be counted as the Tenth Doctor. Because of these anomalies, the numbering is 2 places out of step with what would otherwise be expected after 12 regenerations & the final incarnation of the Doctor's first regeneration cycle is the Eleventh Doctor, not the Thirteenth. That's why, in "The Time of the Doctor", he was dying of old age & unable to regenerate again -- until the Time Lords granted him a new cycle of regenerations. He used the first regeneration of this new cycle to become the Twelfth Doctor. According to "Kill the Moon", the Doctor doesn't know how many more times he'll be able to regenerate &, according to "Hell Bent", Rassilon doesn't know either.