The value of X is determined as the ability starts to resolve. If the targeted player has five cards in their graveyard at that time, for example, this ability will put five more cards into that graveyard from the top of that player's library.