Answer:
She had to had like 20 since (-17-3)= -20 right the question asked how much she had before, she had 20 if not 28, since the mother gave her another twenty but as a result, in the beginning, she had around 28 dollars in order to spend 17 on a book and 3 on a cupcake so she still had 8 dollars, and the 20, well the mother handed her 20.
(I hoped I made sense, and that I helped!:)