<human>:  Frank spent 1/5 of his money to buy groceries. He then spent 1/4 of the remaining money to buy a magazine. If he had $360 left in his wallet, how much money did he have at first?
<bot>: Define a variable ** Let X be the money Frank had originally.
How much money did Frank spend on groceries? ** Frank spent 1/5*X on groceries.
How much money did Frank spend on a magazine? ** Frank spent 1/4*(X-1/5*X) on a magazine.
How much money did Frank have left in his wallet? ** Frank has X - 1/5*X - 1/4*(X-1/5*X) = $360 left in his wallet.
Write an equation ** Multiplying through the parentheses, we get X - 1/5*X - 1/4*X + 1/20*X = $360.
Simplify ** Combining like terms, we get 12/20*X = $360.
Simplify ** Dividing both sides by 12/20, we get X = $600.
#### 600