The answer is 22, but the previous reply is a bit off in the thought process. The correct calculations made to determine that number are as follows:
Including the failed Apollo 13 mission, there were a total of nine missions to the moon - Apollo 8, 10, 11, 12, 13, 14, 15, 16, and 17. Each mission had a crew of three astronauts for a total of 27 "passengers". Three men went twice - John Young on Apollo 10 and 16, Eugene Cernan on 10 and 17, and Jim Lovell on 8 and 13 - which sets the total number of men who have gone to the moon at 24.
Of those 24, they all went into orbit around the moon except for Jack Swigert and Fred Haise - which ultimately sets the total at 22. Swigert and Haise were part of the crew of Apollo 13, along with Jim Lovell who had previously orbited the moon during Apollo 8. Apollo 13 only passed around the moon, using free-return trajectory to help propel the crippled spacecraft back to Earth.
https://en.wikipedia.org/wiki/List_of_Apollo_astronauts
On a side note, Apollo 7 and 9 did not go to the moon, but rather were missions to test equipment and maneuvering techniques while in Earth orbit.
https://en.wikipedia.org/wiki/Apollo_7
https://en.wikipedia.org/wiki/Apollo_9