#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> v;
int a=(1ll<<60) - 1ll, b, n, nr, k,x;
ifstream f ("tomi.in");
ofstream g ("tomi.out");
f >> n >> k;
for (int i = 1; i <= n; i++){
f>>x;
v.push_back(x);
}
for (int i = 59; i >= 0; i--){
b = a ^ (1ll<<i);
nr = 0;
for (int j = 1; j <= n; j++)
if ((v[j] | b) == b) nr++;
if (nr >= k)
a = b;
}
g << a << endl;
return 0;
}