Given,
The number 1,2,3,....,7
Now total numbers of 7 digit number will be 7! without repetition,
Now total numbers which contain string 154 will be 5!
Total numbers which contain string 2367 will be 4!
And number which contain both string 2367&154 will be 2
So, total number which does not contain string 154 or 2367 will be 7!−(5!+4!−2)
=5040−(120+24−2)
=5040−142=4898
Hence this is the required answer.