using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var p = cin.SplitReadL();
            long N = p[0];
            long K = p[1];
            long[] A = cin.SplitReadL();
            const int m = 46;
            long[,] dp = new long[m, 2];

            for(var i = 0; i < m; i++)
            {
                dp[i, 0] = 0;
                dp[i, 1] = -1;
            }

            dp[m - 1, 0] = 0;
            for(var i = m - 2; i >= 0; i--)
            {
                long b = 1L << i;
                long c = 0;
                for(var j = 0; j < N; j++)
                {
                    c += XorCheck(A[j], b);
                }

                long d0 = b * c;
                long d1 = b * (N - c);

                if ((K & b) != 0)
                {
                    dp[i, 0] = Max(dp[i, 0], dp[i + 1, 0] + d1);
                    dp[i, 1] = Max(dp[i, 1], dp[i + 1, 0] + d0);
                }
                else
                {
                    dp[i, 0] = Max(dp[i, 0], dp[i + 1, 0] + d0);
                }
                //一致する方からの遷移

                if (dp[i + 1, 1] != -1)//dpがvalidなら遷移
                {
                    dp[i, 1] = Max(dp[i, 1], dp[i + 1, 1] + Max(d0, d1));
                }
                
            }
            Console.WriteLine(Max(dp[0, 0], dp[0, 1]));
           
            //Console.Out.Flush();
        }
        
        public static int XorCheck(long A,long x)
        {
            long c = A ^ x;
            return c == A + x ? 0 : 1;
        }
        

    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long ModuloP(long value, long mod)
        {
            long r = value % mod;

            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }

    }

   struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
   {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
   }

    


}






Measured memory_bytes: 31324