Carbon, nitrogen, and oxygen abundances in G and K giants