import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 62) # md = 10**9+7 md = 998244353 from collections import defaultdict from random import randrange class Defaultdict(defaultdict): def __init__(self, df): super().__init__(df) self.x = randrange(1 << 31) def __setitem__(self, key, value): super().__setitem__(key ^ self.x, value) def __getitem__(self, item): return super().__getitem__(item ^ self.x) def __missing__(self, key): return super().__missing__(key ^ self.x) def __iter__(self): for a in super().__iter__(): yield a ^ self.x def __contains__(self, item): return super().__contains__(item ^ self.x) def __delitem__(self, key): super().__delitem__(key ^ self.x) def items(self): return [(k ^ self.x, v) for k, v in super().items()] class Set(set): def __init__(self): super().__init__() self.x = randrange(1 << 31) def add(self, a): super().add(a ^ self.x) def pop(self): return super().pop() ^ self.x def remove(self, a): super().remove(a ^ self.x) def discard(self, a): super().discard(a ^ self.x) def __contains__(self, item): return super().__contains__(item ^ self.x) def __iter__(self): for a in super().__iter__(): yield a ^ self.x def chmax(t, nt): ndp[nt] = max(ndp[nt], dp[t]+abs(nt-t)) n, t = LI() aa = LI() dp = Defaultdict(int) dp[t] = 0 for a in aa: ndp = Defaultdict(int) for t in dp: chmax(t,t|a) chmax(t,t&a) dp=ndp print(max(dp.values()))