For every two green M&Ms, there are 5 yellow M&Ms. There are only those two colors.
I'm going to assume every M&M is whole--no fractions of an M&M.
Because the fraction 2/5 cannot be reduced, the number of M&Ms must be some multiple of 7. That's our smallest number.
If there's one set, that's 7 M&Ms
If there are two sets, that's 14 M&Ms: 4 green and 10 yellow.
Three sets: 6 + 15 is 21 M&Ms.
If in another problem, you have a different arrangement, say 4 blue for every 6 brown.
We could have 4+6 = 10 M&Ms,
but 4/6 can be reduced to 2/3 -- two blue for every 3 brown. So our smallest number of M&Ms in that case would be 5.
In general, for this problem type, reduce the fraction, then add the numerator and denominator.