By checking all approximately 8.7x10^45 reachable chess positions?
That's a large overestimate.
https://github.com/tromp/ChessPositionRanking accurately estimates the number of legal chess positions at ~4.8x10^44.
I filed an issue at lechmazur/ChessCounter#1 long ago but its author seems to no longer maintain the project.