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 x,y in now: p1=[[],[]] p2=[[],[]] for v in x: if v&p: p1[0].append(v) else: p2[0].append(v) for v in y: if v&p: p1[1].append(v) else: p2[1].append(v) if p1[0] and p1[1]: now2.append(p1) if p2[0] and p2[1]: now2.append(p2) else: cnt+=c for x,y in now: p1=[[],[]] p2=[[],[]] for v in x: if v&p: p1[0].append(v) else: p2[1].append(v) for v in y: if v&p: p2[0].append(v) else: p1[1].append(v) if p1[0] and p1[1]: now2.append(p1) if p2[0] and p2[1]: now2.append(p2) now=now2 print(now[0][0][0]^now[0][1][0])