---
title: "Letter-Envelope Derangement with At Most Two Correct Placements"
organization: "NityaDhi Digital Mathematics Lab (Asa Edtech Private Limited)"
url: "https://www.nityadhi.com/problems/hard-c11-w1-14-derangements-at-most-two-fixed"
board: "JEE Foundation"
grade: "Class 11"
published_at: "2026-11-28T12:45:00+05:30"
---

# Letter-Envelope Derangement with At Most Two Correct Placements

A secretary has $6$ distinct letters and $6$ corresponding addressed envelopes. In how many ways can all $6$ letters be placed into the envelopes (one letter per envelope) such that **at most $2$** letters are placed in their correct envelopes?

## Textbook Solution

Having at most $2$ letters in their correct envelopes means exactly $0$, $1$, or $2$ letters are placed correctly, while the remaining $6$, $5$, or $4$ letters are completely deranged.
Recall the derangement formula $D_n = n! \sum_{k=0}^{n} \frac{(-1)^k}{k!}$ (or recurrence $D_n = (n-1)(D_{n-1} + D_{n-2})$ with $D_0 = 1, D_1 = 0$):
- $D_2 = 1(0 + 1) = 1$
- $D_3 = 2(1 + 0) = 2$
- $D_4 = 3(2 + 1) = 9$
- $D_5 = 4(9 + 2) = 44$
- $D_6 = 5(44 + 9) = 265$

Now count each valid case:
1. **Exactly $0$ correct letters:** $\binom{6}{0} D_6 = 1 \times 265 = 265$.
2. **Exactly $1$ correct letter:** $\binom{6}{1} D_5 = 6 \times 44 = 264$.
3. **Exactly $2$ correct letters:** $\binom{6}{2} D_4 = 15 \times 9 = 135$.

Summing the three mutually exclusive cases:
$$\text{Total ways} = 265 + 264 + 135 = 664$$

## Vedic Shortcut

**NityaDhi Complement Check & Recurrence Trick:** Always cross-verify by subtracting the forbidden cases ($3, 4, 5, 6$ correct) from $6! = 720$:
- $6$ correct: $1$
- $5$ correct: $0$ (impossible if 5 are right, the 6th must be right!)
- $4$ correct: $\binom{6}{4} D_2 = 15 \times 1 = 15$
- $3$ correct: $\binom{6}{3} D_3 = 20 \times 2 = 40$
Total forbidden $= 1 + 0 + 15 + 40 = 56$, so valid ways $= 720 - 56 = 664$. Notice also $D_n = \text{nearest integer to } \frac{n!}{e}$ for $n \ge 1$, making $D_4=9, D_5=44, D_6=265$ effortless to verify!

## Common Mistakes

1. **Including $5$ correct letters as $\binom{6}{5} = 6$:** If $5$ letters match their envelopes, the $6$-th letter automatically matches its own envelope, so $D_1 = 0$.
2. **Missing the $3$-correct case in complement subtraction:** Subtracting only $1 + 15$ from $720$ gives $704$, forgetting $\binom{6}{3}D_3 = 40$.