IMO 1966 LL HUN18

Solve the equation

IMO 1966 LL HUN18

Origin: HUN

Problem

Solve the equation sin x + cos x = 1 p, where p is a real parameter. Discuss for which values of p the equation has at least one real solution and determine the number of solutions in [0, 2\pi) for a given p.