A chef had 40 apples and 54 peaches. After making some pies, he had 39 apples left. How many apples did he use?
Let's say that x is the number of apples used in pies. 

Then we have the following equation: 

40 - x + 54 = 39 

We can solve it for x: 

40 - x = -15 

x = 55 

So, the chef used 55 apples in pies.