solve #3 problem