I'm finding how many integers under a limit, $L$, only have prime factors from a given set of prime numbers, $P$. The numbers that meet these conditions are called n-smooth numbers. (I've never used sets before so feel free to correct any mistakes I make). Take, for example, $P = \left\{2, 3 \right\}$, and $L = 25$, there are 10 numbers that are 3-smooth: 2, 3, 4, 6, 8, 9, 12, 16, 18, 24.
I'm trying to find a method/algorithm that easily finds how many n-smooth numbers there are for a given $P$ and $L$. Here's my work so far:
To start, a number from $P$ to any power will be n-smooth as long as it's < $L$. Using the same example from above, this would include the powers of two: 2, 4, 8, 16, and the powers of three: 3, 9. By using the floor function and log, I can essentially tell how many powers of a number there are that are less than or equal to L. The total amount of these numbers can be modeled with this expression:
But this leaves the other numbers 6, 12, 18, and 24 leftover. I don't know how to account for these "leftover" type of numbers. Does anyone have any ideas?

$$\# \{m \le L | m=2^a 3^b \} = \sum_{a=0}^{\lfloor \frac{\log L}{\log 2}\rfloor} \lfloor \frac{\log L - a\log 2}{\log 3}\rfloor$$
For $L = 25$, it gives :
$$\lfloor \frac{\log L }{\log 3}\rfloor+\lfloor \frac{\log L - \log 2}{\log 3}\rfloor+\lfloor \frac{\log L - 2\log 2}{\log 3}\rfloor+\lfloor \frac{\log L - 3\log 2}{\log 3}\rfloor+ \lfloor \frac{\log L - 4\log 2}{\log 3}\rfloor$$ $$= \# \{1,3,9\} +\# \{2,6,18\}+\# \{4,12\}+\# \{8,24\}+\# \{16\} = 11$$