Contiguous Subsequence XOR

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

Medium7Bit manipulationTriePrefix sumNo attempts yetTime limit1sMemory limit512 MB

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 iji \le j. Its XOR is AiAi+1AjA_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. (1N100,0001 \le N \le 100{,}000, 1K1,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. (1Ai100,0001 \le A_i \le 100{,}000)

Output

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