import java.util.*;

public class Main {
    public static void main(String[] args) {
        int[] arr = new int[]{4, 2, 2, 6, 4};
        int k = 6;
        
        System.out.println(countSubarraysWithXOR(arr, k));
    }

    public static int countSubarraysWithXOR(int[] arr, int k) {
       
        Map<Integer, Integer> map = new HashMap<>();
        
        // Putting a prefix XOR of 0 has occurred once initially
        map.put(0, 1);
        
        int currentXOR = 0;
        int count = 0;
        
        for (int num : arr) {
            // Update the running prefix XOR
            currentXOR ^= num;
            
            // Looking for the required prefix XOR value that satisfies the property
            int targetXOR = currentXOR ^ k;
            
            // If the target prefix XOR exists, add its frequency to our count
            if (map.containsKey(targetXOR)) {
                count += map.get(targetXOR);
            }
            
            // Record the current prefix XOR frequency in the map
            map.put(currentXOR, map.getOrDefault(currentXOR, 0) + 1);
        }
        
        return count;
    }
}
