X can't be greater than the number of players in the game.
Reveal cards from the top of your library until you reveal X land cards. Put those land cards onto the battlefield tapped and the rest on the bottom of your library in a random order.
The number of players in the game is checked only as you choose the value for X. Once you've cast Open the Way, players leaving the game in response to the spell won't affect the number of land cards you'll find.