There’s a whole Wikipedia page devoted to the topic of the numbering of the 21 or so different popes who have been named John something, with the last one being John XXIII, who reigned (or whatever they call it) from 1958 to 1963. As the article explains: “Although there have been twenty-one legitimate popes named John, the numbering has reached John XXIII because of two clerical errors that were introduced in the Middle Ages: first, antipope John XVI was kept in the numbering sequence instead of being removed; then, the number XX was skipped because pope John XXI counted John XIV twice.”