For this case we have to:
x: Let the variable that represents the initial amount of jelly beans in the bag
So:
Maggie ate[tex]\frac {1} {5}[/tex]of the jelly beans:
[tex]\frac {1} {5} x[/tex]
Then he ate 40 jelly beans:
[tex]\frac {1} {5} x-40[/tex]
In those two days he ate a total of 107 jelly beans:
[tex]\frac {1} {5} x + 40 = 107[/tex]
We clear the value of the variable "x":
[tex]\frac {1} {5} x = 107-40\\\frac {1} {5} x = 67\\x = 67 * 5\\x = 335[/tex]
Answer:
The initial quantity of jelly beans was 335