There are lots of resources for the different Ender 3 models online, its design is open source after all.
https://docs.sainsmart.com/article/fkyuwu4jhq-ender-3-v-2-3-d-printer
https://m.media-amazon.com/images/I/B1f9eP6H3OS.pdf
Looks like both of those say you need an M5x45 screw. That is, an M5 sized screw that's 45mm long: https://www.amazon.com/iExcell-Thread-Socket-Screws-Finish/dp/B08S7FLZ1D
And they're also both saying that each screw comes with a spring washer, to keep tension on the gantry: https://www.amazon.com/uxcell-Stainless-Spring-Washers-Gasket/dp/B0152FRDFM/
But first, I would check the ends of the gantry arms to make sure the screws weren't just stuck in there for safekeeping.
EDIT: to be more specific, the BOTTOM of the gantry is held by M5x45, but the TOP of the gantry is M5x25.