Let us count the legal passwords of length $5$. If there were no restrictions, it would be $62^5$.
But some of these strings are bad. We count the bad strings of length $5$. There are $52^5$ strings with no digit. There are $36^5$ strings with nothing from A-Z. And there are $36^5$ with nothing from a-z.
If we add these three numbers, we will have double-counted the all digit words, the all caps word, and the all a-z words. There is a total of $10^5+26^5+26^5$ of these. Thus the number of bad strings of length $5$ is
$$52^5+36^5+36^5-10^5-26^5-26^5.$$
Subtract from $62^5$ to get the number of legal passwords of length $5$.
Repeat for $6$ characters and add.
Remark: The fancy name for the idea we used is the Principle of Inclusion/Exclusion.