Lamp Corridor Toggles
The maintenance corridor has 30 lamps, numbered 0 through 29, strung along the ceiling. All of them start switched off.
Along the corridor stand n switch panels, numbered 1 to n from one end to the other. Panel i is wired to a 30-bit mask s_i: pressing panel i once flips every lamp whose bit is set in s_i (on becomes off, off becomes on) and leaves every other lamp exactly as it was.
Pressing a sequence of panels flips each lamp once for every panel in the sequence that controls it, so the lamps' final state depends only on which panels were pressed — not on the order they were pressed in. In particular, if you press a whole run of panels, the result is the same no matter what order you press them in.
A stretch is a run of consecutive panels l, l+1, …, r (1 ≤ l ≤ r ≤ n). Starting from all lamps off, suppose every panel in a stretch gets pressed exactly once. Count the number of stretches [l, r] for which the lamps end up showing exactly the target pattern K — that is, lamp b is lit after pressing the stretch if and only if bit b of K is 1.
Input
The first line contains two integers n and K (1 ≤ n ≤ 2·10^5, 0 ≤ K < 2^30).
The second line contains n integers s_1, …, s_n (0 ≤ s_i < 2^30), the mask wired to each panel.
Output
Print a single integer: the number of stretches [l, r] whose combined toggles leave the lamps showing exactly pattern K. The answer may exceed the range of a 32-bit integer.
Notes
In the first example, pressing panels 1, 4, 2–3, or 1–4 each leave the lamps showing pattern 5; no other stretch does.