$10$ letters are placed in $10$ addressed envelopes. Find the number of ways such that at most three letters are not in correct envelopes

There is exactly one way for all letters to be in their right envelopes.

It's impossible for exactly one letter to be in the wrong envelope, because if letter A is in envelope B, then letter B must also be in the wrong envelope.

For any way of putting exactly two letters in the wrong envelopes, you can get there by having all letters in the correct envelopes, then choose two letters and swap them. Therefore this can happen in $\binom{10}2$ ways.

Finally, for three letters in the wrong envelopes, it's more or less like the above: start with a perfect ordering, choose three letters and then derange them. There are two derangements on three elements, so there are $2\cdot \binom{10}{3}$ ways of doing this.


You've gotten confused about the derangements. As I said in a comment, there is no way for there to be exactly one letter in the wrong envelope. What about the case of two letter in the wrong envelope? The remaining eight letters are placed in the correct envelope, so we are concerned with the number of derangements of the two wrongly-place letters. That is we have $${10\choose2}\cdot D_2=45$$ ways for this case. Do same for the case where exactly $3$ letters are not in correct position.