Not so easy math question from bitmasking challenges

How can this question be solved in better time complexity than brute force? (CHALLENGES-BITMASKING)

using principle of inclusion and exclusion.
watch it here