After buying a hat, Josh has $20 - $10 = $<<20-10=10>>10
After buying a pencil, Josh has $10 - $2 = $<<10-2=8>>8
The total cost of cookies is 4 * $1.25 = $<<4*1.25=5>>5
After buying the cookies, Josh has $8 - $5 = $<<8-5=3>>3
#### 3