Fred had some marbles. He gave 1/4 of the marbles and another 34 marbles to Gillan. He then gave 3/8 of the remaining marbles and another 40 marbles to John. He had 580 marbles left in the end. How many marbles did Free have at first?
We set all the marbles Fred has as X.
We can infer from the first sentence that: X - (1/4X+34) = 3/4X - 34 marbles is what Fred has after the first sentence
Now, 3/4X - 3/8(3/4x - 34) = 3/4X-9/32X+51/4 = 15/32X+51/4 is what he has after the second sentence
That suggests that 15/32X + 51/4 = 580, which means 15/32X = 2551/4, and find X to get the answer to the question.