Improved counting shows the maximum to occur at 28 pieces [1] (also see the issue I filed on your github repo).
[1] https://www.chess.com/forum/view/general/on-the-number-of-ch...
> Upper bound estimate of possible legal chess position (counts en passant, castling, sides to move, allows underpromotions): 8.7E+45.
But how exactly is this number determined? Is this a sampling based estimate?
My 8726713169886222032347729969256422370854716254 is an exact upperbound on the number of so-called urpositions, and is not sampling based.
In any case it will be easier to continue this discussion at https://github.com/lechmazur/ChessCounter/issues/1