1st solution is overcomplicated

`(d not in '347' for d in S)`

and `(d in '2569' for d in S)`

are too expensive

Below is 2x faster

A good number is a number which has none of bad digits( {3,4,7} ) and at least one good digit( {2,5,6,9} }

```
bad = ['3', '4', '7']
good = ['2', '5', '6', '9']
ans = 0
for i in map( str, range( 1, N + 1 )):
to_continue = True
for k in bad:
if k in i:
to_continue = False
break
if to_continue:
for k in good:
if k in i:
ans += 1
break
return ans
```