.
After seeing the solutions from two our respectful tutors, you, probably, have a wish to see something more simple.
I will try to satisfy this desire by presenting as simple solution as possible.
From the condition, it is clear that the number of marbles Josh had initially, is multiple of 4.
Let x be 1/4 of Josh's marbles, that he had initially.
So, Josh had initially 4x marbles; at the first exchange, he gave 1/4 of it, i.e. x marbles, to May.
Thus after first exchange, Josh left with 3x marbles, while May had 3 times 3x marbles, i.e. 9x marbles.
After the second exchange, Josh has (3x+12) marbles, while May has (9x-12) marbles.
These amounts are the same, so you have this simple equation
3x + 12 = 9x - 12.
You can EASILY solve it :
12 + 12 = 9x - 3x, or 24 = 6x, which implies x= 24/6 = 4.
Thus Josh had initially 4x = 16 marbles.
After first exchange, May had 9x = 9*4 = 36 marbles; but 4 of them came from Josh (! remember, x= 4 !),
so May had initially 36 - 4 = 32 marbles. ANSWER
Solved.