import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0].to!int;
    auto K = s[1];
    auto A = readln.split.map!(to!long).array;

    long X = 0;
    auto B = K.bsr + 1;
    bool less = false;

    foreach_reverse (i; 0..B) {
        if (!less && !(K & (1L << i))) {
            continue;
        }

        long y = 0;
        long z = 0;
        foreach (a; A) {
            if (a & (1L << i)) {
                y += 1;
            } else {
                z += 1;
            }
        }

        if (y > z) {
            if (!less) less = true;
        } else {
            X += (1L << i);
        }
    }

    long ans = 0;
    foreach (a; A) ans += (X ^ a);
    ans.writeln;
}
