## Task B-4.4.

How many passwords consisting of 4 characters from the set $\{a, b, c, 1,2,3,4,5,+,!\}$ are there such that all characters in the password are different or the password contains exactly two, not necessarily different letters and two, not necessarily different digits?
## Solution.

First, let's count the passwords consisting of four characters from the given set, where all characters are different. The first character of the password can be chosen in 10 ways (any of the provided characters), the second character in 9 ways (it must be different from the first chosen character), the third character in 8 ways, and the fourth in 7 ways. Therefore, there are \(10 \times 9 \times 8 \times 7 = 5040\) such passwords.

Now, let's count the passwords that contain exactly two letters and two digits. From the four characters in the password, or the four positions for the characters, the positions where the two letters will be can be chosen in \(\binom{4}{2} = 6\) ways, and the letters at these positions can be chosen in \(3 \times 3\) ways. The remaining two positions in the password will be digits, and they can be chosen in \(5 \times 5\) ways. Therefore, the number of passwords that contain exactly two letters and two digits is \(6 \times 3^2 \times 5^2 = 1350\).

The number of passwords where all characters are different and that contain exactly two letters and two digits is \(\binom{4}{2} \times 3 \times 2 \times 5 \times 4 = 720\).

The desired number of passwords is \(5040 + 1350 - 720 = 5670\).