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