n,k=map(int,input().split()) k*=2 k+=n-1 a=list(map(int,input().split())) now=[[a,a]] ans=0 cnt=0 for i in range(30)[::-1]: xx=[] yy=[] c=0 p=1<k: for v in range(len(xx)): if xx[v][0] and yy[v][0]: now.append([xx[v][0],yy[v][0]]) if xx[v][1] and yy[v][1]: now.append([xx[v][1],yy[v][1]]) else: cnt+=c for v in range(len(xx)): if xx[v][0] and yy[v][1]: now.append([xx[v][0],yy[v][1]]) if xx[v][1] and yy[v][0]: now.append([xx[v][1],yy[v][0]]) print(now[0][0][0]^now[0][1][0])