N, K = map(int, input().split()) A = list(map(int, input().split())) for _ in range(201): next = 0 count = 0 for a in reversed(A): count += 1 next ^= a if count == N: break A.append(next) print(A[K-1])