Sum of special numbers

Given a range [l; r], you would like to know how many special numbers are there in that range. A number n is special if its power of 3 is divisible by 5 or by 7 ( is divisible by 5 or 7).
The input contains 2 numbers l and r (1 ≤ l ≤ r ≤ 1000).
Print how many special numbers are there in the [l; r] range (the range is inclusive).
Input
Output
1 100
32
3 7
2
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in