You are given two positive integers S and X. Count the ordered pairs (A,B) of positive integers that satisfy A+B=S and A⊕B=X, where ⊕ is the bitwise exclusive or.
Both A and B must be at least 1. If A=B, then (A,B) and (B,A) count as two different pairs.