Let $1; 4; 7; \cdots$ and $9; 16; 23; \cdots$ be two arithmetic progressions. The set $S$ is the union of the first $2004$ terms of each sequence. How many distinct numbers are in $S$?

Let's think step by step and output the final answer within \boxed{}.
user