6. The sequence of positive integers $\left\{a_{n}\right\}: a_{n}=3 n+2$ and $\left\{b_{n}\right\}$ : $b_{n}=5 n+3(n \in \mathbf{N})$ have a common number of terms in $M=\{1,2, \cdots, 2018\}$ which is $\qquad$ .
6. 135.

It is known that 2018 is the largest common term of the two sequences within $M$. Excluding this common term, subtract 2018 from the remaining terms of $\left\{a_{n}\right\}$ and $\left\{b_{n}\right\}$, respectively, to get
$$
\left\{\overline{a_{n}}\right\}=\{3,6,9, \cdots, 2016\},
$$

which are all multiples of 3 within $M$; and
$$
\left\{\overline{b_{n}}\right\}=\{5,10,15, \cdots, 2015\},
$$

which are all multiples of 5 within $M$.
Clearly, the common terms of $\left\{a_{n}\right\}$ and $\left\{b_{n}\right\}$ correspond one-to-one to the common terms of $\left\{\overline{a_{n}}\right\}$ and $\left\{\overline{b_{n}}\right\}$, and these common terms are all multiples of 15 within $M$, which are $\left[\frac{2018}{15}\right]=134$, where $[x]$ denotes the greatest integer not exceeding the real number $x$.
Therefore, the number of common terms sought is $134+1=135$.