Can someone provide an explanation for the solution here. Not understanding ETS’s explanation. I got this right by guessing.

Hint: think about extremes. What is the maximum number of pencils he can take such that he does **not** need to have at least two pencils of each colour?