Let $a_1,a_2,\ldots$ be a sequence determined by the rule $a_n=\frac{a_{n-1}}{2}$ if $a_{n-1}$ is even and $a_n=3a_{n-1}+1$ if $a_{n-1}$ is odd. Find the number of positive integers $a_1 \le 2008$ for which $a_1$ is less than each of $a_2$, $a_3$, and $a_4$.

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