#include using namespace std; typedef long long ll; typedef double lf; typedef pair pii; typedef pair pll; #define TRACE(x) cerr << #x << ' ' << x << endl #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define _ << ' ' << #define fi first #define sec second #define se second #define mp make_pair #define pb push_back int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int sol = 0; for (int i = 31; i >= 0; i--) { int cnt = 0; for (int x : a) if ((1 << i) & x) cnt++; if (cnt >= k) { vector tmp; for (int x : a) if ((1 << i) & x) tmp.push_back(x); a = tmp; sol += (1 << i); } } cout << sol; return 0; }