Ryan initially had 51 quarters in his piggy bank, instead of 9. He still uses 3 quarters to buy a pencil from the school bookstore. How many quarters does he have left in his piggy bank after his purchase in this scenario?