How to set token uri data name to include "mint number"

Hey
I'm working on an NFT minting contract that let the user mint random generated images from a webpage. I would like to include the "mint number" as a part of the metadate name, like so "#021 NFT".
At this moment I'm generating the metadata, uploading it to ipfs, and then minting the token, but I'm unsure how I should add the mint number pre-mint. I could check the amount of currently minted tokens and use that in the pre-generated metadata, but what if two mint calls are made before the chain updates - then both mints would get the same number.

Is there sort of an best practice kind of way of doing this?