Let's denote what you called a "constraint" as . Now, you can only make pairs of numbers and , such that , when . Therefore, there are pairs you can make with , pairs with , pairs with , ... , and pair with the number: is the numbers of pairs you seek.