.
At most 2 flags means 2 or 1 or 0 (if consider the absence of flags as a special signal).
So, you can display 5 signals, showing any one single separate flag of five flags that you have.
Next, you can display 5*4 = 20 signals, showing ordered pairs of distinct flags.
So, you can display, in total, 5 + 20 = 25 signals using 1 or 2 flags.
If there is an agreement that the absence of flags is a special signal, too, then you can display 25 + 1 = 26 signals.
Solved, answered and explained.
Notice that 26 is exactly the number of letters in English alphabet (!)