import sys, time, random from collections import deque, Counter, defaultdict def debug(*x):print('debug:',*x, file=sys.stderr) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 def xor_str(x, y): return ''.join(str(int(a) ^ int(b)) for a, b in zip(x, y)) n, k = mi() a = li() prefix_counter = Counter() A = [] for v in a: s = bin(v)[2:] while len(s) < 30: s = '0' + s A.append(s) for i in range(30): prefix_counter[s[:i+1]] += 1 ans = '' for i in range(30): #まず0を付けると仮定 zans = ans + '0' zcnt = 0 for v in A: prefix_counter[v[:len(zans)]] -= 1 tocnt = xor_str(zans, v[:len(zans)]) zcnt += prefix_counter[tocnt] if zcnt >= k: ans += '0' else: ans += '1' k -= zcnt print(int(ans, 2))