Program Captain;
Var n,k,i,j,t,max:longint;
a:array[0..100000]of longint;
F:array[0..2000001]of longint;
Begin
Assign(input,'xorxor.in');Reset(input);
Assign(output,'xorxor.out');Rewrite(output);
Readln(n,k);t:=0;max:=-1;
For i:=1 to n do Read(a[i]);
For i:=1 to n-1 do
For j:=i+1 to n do begin
t:=a[i] xor a[j];
inc(F[t]);
If t>max then max:=t;
End;i:=-1;
While k>0 do begin
inc(i);
If f[i]>0 then begin
DEC(K);Dec(f[i]);
If f[i]>0 then Dec(i);
End;
End;
Writeln(i);
Close(input);Close(output);
End.