Under construction

Still being built. Things may change

Contiguous Subsequence XOR

Time limit1sMemory limit512 MB

Summary
Count contiguous subsequences of the given sequence whose bitwise XOR is less than K.
Level

Medium7 of 10

Topics
Bit manipulation, Trie, Prefix sum
Solved
No attempts yet

Problem

You are given a sequence A1,A2,…,ANA_1, A_2, \dots, A_N of length NN. Count the contiguous subsequences whose XOR is less than KK.

A contiguous subsequence is Ai,Ai+1,…,AjA_i, A_{i+1}, \dots, A_j for a pair of indices with i≤ji \le j. Its XOR is Ai⊕Ai+1⊕⋯⊕AjA_i \oplus A_{i+1} \oplus \dots \oplus A_j, where ⊕\oplus is the bitwise exclusive or.

Two contiguous subsequences with a different start position or a different end position count separately, even when their elements have the same values.

Input

The first line contains NN and KK, separated by a space. (1≤N≤100,0001 \le N \le 100{,}000, 1≤K≤1,000,0001 \le K \le 1{,}000{,}000)

The second line contains A1,A2,…,ANA_1, A_2, \dots, A_N in order, separated by spaces. (1≤Ai≤100,0001 \le A_i \le 100{,}000)

Output

Print the number of contiguous subsequences whose XOR is less than KK on the first line.

Examples3

  1. Example 1

    Input
    5 2
    4 1 3 2 7
    
    Expected output
    3
    
  2. Example 2

    Input
    1 1
    1
    
    Expected output
    0
    
  3. Example 3

    Input
    1 2
    1
    
    Expected output
    1