11. (20 points) Let $a_{1} \in \mathbf{Z}_{+}$, and $a_{1} \leqslant 18$, define the sequence $\left\{a_{n}\right\}:$
$$
a_{n+1}=\left\{\begin{array}{ll}
2 a_{n}, & a_{n} \leqslant 18 ; \\
2 a_{n}-36, & a_{n}>18
\end{array}(n=1,2, \cdots) .\right.
$$

Find the maximum number of elements in the set $M=\left\{a_{n} \mid n \in \mathbf{Z}_{+}\right\}$.
11. Given the positive integer $a_{1} \leqslant 18$ and the recursive formula for the sequence $\left\{a_{n}\right\}$, the following properties can be derived:
(1) $a_{n+1} \equiv 2 a_{n}(\bmod 36)$, i.e.,
$a_{n+1} \equiv 2 a_{n}(\bmod 4)$, and $a_{n+1} \equiv 2 a_{n}(\bmod 9)$;
(2) All terms are positive integers, and for any $n \in$ $\mathbf{Z}_{+}, a_{n} \leqslant 36$;
(3) From the third term onwards, all terms are multiples of 4, i.e., for any $n \geqslant 3,4 \mid a_{n}$;
(4) $3\left|a_{n} \Leftrightarrow 3\right| a_{1}$, i.e., if $a_{1}$ is a multiple of 3, then all terms are multiples of 3; otherwise, none of the terms are multiples of 3.
Consider the maximum value of $|M|$ in the following two scenarios.
【Scenario 1】If $3 \mid a_{1}$, then consider $a_{3}$.
(i) $\left\{\begin{array}{l}a_{3} \equiv 3(\bmod 9), \\ a_{3} \equiv 0(\bmod 4) .\end{array}\right.$
By the Chinese Remainder Theorem, we get
$$
\begin{array}{l}
a_{3} \equiv 12(\bmod 36) \Rightarrow a_{3} \equiv 12 \\
\Rightarrow\left(a_{3}, a_{4}, a_{5}, a_{6}, \cdots\right) \equiv(12,24,12,24, \cdots) .
\end{array}
$$

Considering the first two terms, we get $|M| \leqslant 4$.
(ii) $\left\{\begin{array}{l}a_{3} \equiv 6(\bmod 9) \\ a_{3} \equiv 0(\bmod 4)\end{array}\right.$.

By the Chinese Remainder Theorem, we get
$$
\begin{array}{l}
a_{3} \equiv 24(\bmod 36) \\
\Rightarrow\left(a_{3}, a_{4}, a_{5}, a_{6}, \cdots\right) \equiv(24,12,24,12, \cdots) .
\end{array}
$$

Considering the first two terms, we get $|M| \leqslant 4$.
(iii) $\left\{\begin{array}{l}a_{3} \equiv 0(\bmod 9), \\ a_{3} \equiv 0(\bmod 4)\end{array}\right.$.

Then $a_{3} \equiv 0(\bmod 36)$
$\Rightarrow\left(a_{3}, a_{4}, a_{5}, \cdots\right) \equiv(36,36,36, \cdots)$.
Considering the first two terms, we get $|M| \leqslant 3$.
【Scenario 2】If $a_{1}$ is not a multiple of 3, then none of the terms in the sequence $\left\{a_{n}\right\}$ are multiples of 3.
In this case, $a_{3} \equiv 1,2,4,5,7,8(\bmod 9)$.
Also, $a_{3} \equiv 0(\bmod 4)$, so by the Chinese Remainder Theorem, we get $a_{3} \equiv 28,20,4,32,16,8(\bmod 36)$.
Therefore, $a_{3} \in\{28,20,4,32,16,8\}$.
Hence, when $n \geqslant 3$, $a_{n} \in\{28,20,4,32,16,8\}$, and $\{28,20,4,32,16,8\} \subset M$.
Considering the first two terms, we get $|M| \leqslant 8$.
Taking $a_{1}=1$, we get the sequence $\left\{a_{n}\right\}$:
$1,2,4,8,16,32,28,20,4, \cdots$.
Thus, the maximum number of elements in the set $M$ is 8.