Sarah bought 2 boxes of pencils. There were 58 pencils in each box. In the first box, 23 of the pencils were red, 18 were blue, and the rest were yellow.

there are 5 total yellow pencils total

you subtract 23-18 and get 5 total yellow pencils.

To find out how many yellow pencils Sarah bought, we need to subtract the number of red and blue pencils from the total number of pencils in the first box.

The total number of pencils in the first box is 58.

So, the number of yellow pencils can be found by subtracting the number of red (23) and blue (18) pencils from 58:

58 - 23 - 18 = 17

Therefore, Sarah bought 17 yellow pencils in the first box.