n, k = map(int, input().split()) a = list(map(int, input().split())) x = 0 for ai in a: x ^= ai a.append(x) n += 1 k = (k - 1) % n print(a[k])