#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vector val(n); for(auto &x : val) cin >> x; for(int i = 29; i >= 0; i--) { vector chosen; for(auto x : val) { if(x & (1 << i)) chosen.push_back(x); } if(chosen.size() >= k) val = chosen; } int res = (1 << 30) - 1; for(auto x : val) res &= x; cout << res << endl; }