Let x be the cost of each notebook. We know that we bought 5 of them, then the total cost of the notebooks is:

We had 21 dollars and we spent 5x on the notebooks, this can be express as:

Finally we know that this is equal to the six dollars we had at the end, then we have the equations:

Solving for x we have:

Therefore each notebook cost $3