A hint to get started
Fill the most constrained digit position first
How many numbers between 3000 and 5000 can be formed using only the digits 1, 2, 3, 4 and 5 if (i) no digit is repeated, (ii) the digits can be repeated, (iii) no repetition is allowed and the numbers are even?
CJC · Lecture · Example 15
Decide whether order matters and repetition is allowed; then count stages or disjoint cases.