Integer sequence $(x_{n})$ is defined as follows; 
$x_{1} = 1$, and for each integer $n \geq 1$, $x_{n+1}$ is equal to the largest number that can be obtained by permutation of the digits of $x_{n}+2$. Find the smallest $n$ for which the decimal representation of $x_{n}$ contains exactly $2022$ digits
1. **Definition and properties of "pretty numbers"**

   Let us call "pretty" a number in the sequence which is  $\ge 100$  and is  in the form  $x=\overbrace{aa...aa}^{\times p}\overbrace{(a-1)(a-1)...(a-1)(a-1)}^{\times q}\overbrace{(a-2)(a-2)...(a-2)(a-2)}^{\times r}$  where  $p,q$  are positive integers,  $r$  is a nonnegative integer and  $a$  is some integer in  $\{1,2,...,9\}$  (with  $r=0$  if  $a=1$ ).

   (Not all the numbers in the sequence are pretty)

   Let us write such a pretty number  $x$  as  $(a,p,q,r)$  (this number contains  $p+q+r$  decimal digits).

2. **Successor of a pretty number**

   Successor of pretty number  $(a,p,q,r)$  is:
   - If  $r\ge 1$: pretty number  $(a,p+1,q,r-1)$
   - If  $r=0$  and  $a\le 8$: pretty number  $(a+1,1,p,q-1)$
   - If  $r=0$  and  $a=9$  and  $q=1$: pretty number  $(1,1,p+1,0)$ (and we increased the number of digits)
   - If  $r=0$  and  $a=9$  and  $q\ge 2$:
     - Successor is not a pretty number:  $\overbrace{99...99}^{\times p+1}\overbrace{88...88}^{\times q-2}0$
     - Next successor is not a pretty number:  $\overbrace{99...99}^{\times p+1}\overbrace{88...88}^{\times q-2}2$
     - Next successor is not a pretty number:  $\overbrace{99...99}^{\times p+1}\overbrace{88...88}^{\times q-2}4$
     - Next successor is not a pretty number:  $\overbrace{99...99}^{\times p+1}\overbrace{88...88}^{\times q-2}6$
     - Next successor is pretty number  $(9,p+1,q-1,0)$

3. **Steps to go from one pretty number to another**

   - We need  $4(p+q)$  steps to go from  $(1,p,q,0)$  to  $(9,p,q,0)$.
     - From  $(1,p,q,0)$, we need one step to reach  $(2,1,p,q-1)$.
     - Then  $q-1$  steps to reach  $(2,q,p,0)$.
     - One step to reach  $(3,1,q,p-1)$.
     - Then  $p-1$  steps to reach  $(3,p,q,0)$.
     - One step to reach  $(4,1,p,q-1)$.
     - Then  $q-1$  steps to reach  $(4,q,p,0)$.
     - One step to reach  $(5,1,q,p-1)$.
     - Then  $p-1$  steps to reach  $(5,p,q,0)$.
     - One step to reach  $(6,1,p,q-1)$.
     - Then  $q-1$  steps to reach  $(6,q,p,0)$.
     - One step to reach  $(7,1,q,p-1)$.
     - Then  $p-1$  steps to reach  $(7,p,q,0)$.
     - One step to reach  $(8,1,p,q-1)$.
     - Then  $q-1$  steps to reach  $(8,q,p,0)$.
     - One step to reach  $(9,1,q,p-1)$.
     - Then  $p-1$  steps to reach  $(9,p,q,0)$.
     - And so  $4(p+q)$  steps to go from  $(1,p,q,0)$  to  $(9,p,q,0)$.
     - Q.E.D.

   - We need  $4p+5$  steps to go from  $(1,p,1,0)$  to  $(1,1,p+1,0)$.
     - We need  $4(p+1)$  steps to go from  $(1,p,1,0)$  to  $(9,p,1,0)$.
     - And successor is  $(1,1,p+1,0)$.
     - Q.E.D.

   - We need  $9q$  steps to go from  $(1,1,q,0)$  to  $(1,1,q+1,0)$  where  $q\ge 2$.
     - We need  $4(1+q)$  steps to go from  $(1,1,q,0)$  to  $(9,1,q,0)$.
     - Then we need  $5$  steps to reach (through four non-pretty numbers  $\overbrace{99...99}^{\times 2}\overbrace{88...88}^{\times q-2}0$  to  $\overbrace{99...99}^{\times 2}\overbrace{88...88}^{\times q-2}6$)  pretty number  $(9,2,q-1,0)$.
     - And so  $5(q-1)$  steps to go from  $(9,1,q,0)$  to  $(9,q,1,0)$.
     - One step to reach  $(1,1,q+1,0)$.
     - Q.E.D.

4. **Number of elements with exactly  $n$  digits in the sequence  $x_n$**

   - There are  $5$  one-digit numbers in the sequence:  $1,3,5,7,9$.
   - There are  $9$  two-digit numbers in the sequence:  $11,31,33,53,55,75,77,97,99$.
   - The first next number (first three-digit number) is  $110$, which is pretty number  $(1,2,1,0)$.
   - Then, using 1.3), we need  $13$  steps to go from  $(1,2,1,0)$  to  $(1,1,3,0)$.
   - And so there are  $13$  three-digit numbers in the sequence.

   From there, we'll only need 1.4 to progress and we get that we have exactly  $9(n-1)$  n-digit numbers where  $n\ge 4$.

5. **Answer**

   The number of elements of less than  $2022$  digits is:
   \[
   5 + 9 + 13 + \sum_{k=4}^{2021} 9(k-1)
   \]
   \[
   = 27 + 9 \cdot \frac{2018 \times 2023}{2}
   \]
   \[
   = 27 + 9 \cdot 2037171
   \]
   \[
   = 27 + 18334539
   \]
   \[
   = 18334566
   \]

   Hence the answer: the first element with  $2022$  digits is  $\boxed{x_{18334567}}$.