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 denote the number of apples used by the chef by a. Then the number of peaches used by the chef is 

54-a. 

The number of apples left after making some pies is 

40-a. 

Therefore the equation is: 

40-a=39 

a=1