Under construction

Still being built. Things may change

XOR Equation

Interview

Time limit2sMemory limit512 MB

Summary
Count ordered pairs of positive integers A and B with A+B=S and A xor B=X.
Level

Medium6 of 10

Topics
Math, Bit manipulation
Solved
No attempts yet

Problem

You are given two positive integers SS and XX. Count the ordered pairs (A,B)(A, B) of positive integers that satisfy A+B=SA + B = S and A⊕B=XA \oplus B = X, where ⊕\oplus is the bitwise exclusive or.

Both AA and BB must be at least 11. If A≠BA \neq B, then (A,B)(A, B) and (B,A)(B, A) count as two different pairs.

Input

The first line contains two positive integers SS and XX, separated by a space. (2≤S,X≤10122 \le S, X \le 10^{12})

Output

Print on the first line the number of ordered pairs (A,B)(A, B) that satisfy both equations.

Examples3

  1. Example 1

    Input
    9 5
    
    Expected output
    4
    
  2. Example 2

    Input
    3 3
    
    Expected output
    2
    
  3. Example 3

    Input
    5 2
    
    Expected output
    0