In a certain apartment building, residents are allowed to own exactly one dog, exactly one cat, or one dog and one cat. No other pets are allowed. There are 22 cats and 17 dogs in the building. If there are 25 apartments that contain only one dog or one cat, how many apartments, in total, contain pets?
Thank you. 🙂