We know that,
$a \equiv b(\bmod x)=\frac{(a-b)}{x}$
Given, $21 \equiv 385(\bmod x)=\frac{(21-385)}{x}$
$=-\frac{364}{x}$...(i)
and $587 \equiv 167(\bmod x)$
$=\frac{(587-167)}{x}=\frac{420}{x}$...(ii)
Now, the greatest value of ' $x$ ' satisfying Eq. (i)
and Eq.(ii) =max [LCM of (364,420)]
$\Rightarrow x $= max (13,15,28)
$\Rightarrow x =28$