from bisect import bisect_left, bisect_right N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort() # A の中で l 以上 r 以下の要素の個数 def count(l, r): return bisect_right(A, r) - bisect_left(A, l) ans = 0 X = 2 * K + N for i in range(30, -1, -1): left = ans right = ans | ((1 << i) - 1) cnt = 0 for a in A: l = left ^ (a & ~((1 << i) - 1)) r = right ^ (a & ~((1 << i) - 1)) cnt += count(l, r) if cnt < X: ans |= 1 << i X -= cnt print(ans)