Using packing fractions of course – the video explains it all and it is interesting way to learn about packing fractions.
What you need to know:
Volume of a single M&M: 4/3 * pi * (a^2) * b = .636 cubic centimeters
Packing fraction for M&Ms: 68%
Number of M&Ms: ((Volume of Jar) / (volume of one M&M)) x (packing fraction) = (volume of jar in cc) * 0.43248
If the volume of your jar is in imperial units (gallons, etc, find out the number of cc in 1 unit and then use 0.43248) (eg: 1 gallon = 3785.411 CC)