#include <iostream>
#include <cstdio>
#include <cmath>
#include <fstream>
using namespace std;
ifstream fin("xorxor.in");
ofstream fout("xorxor.out");
int a[1000],b[1000];
int main () {
int n,k;
cin>>n>>k;
for (int i=0;i<n;i++){
cin>>a[i];
}
for (int i=0;i<n/2;i++){
for (int j=i;j<n;j++)
b[i]=a[i]^a[j];
}
for (int i=n*(n-1)/2-1;i>=0;i--){
for (int j=0;j<i;j++){
if(b[j]>b[j+1])swap(b[j],b[j+1]);
}
}
cout<<b[k-1];
return 0;
}