n,t = map(int,input().split()) a = list(map(int,input().split())) dp = [] for i in range(n+1): dp.append({}) dp[0][t] = 0 for i in range(n): for now, score in dp[i].items(): for j in range(2): nxt = now & a[i] if j == 1: nxt = now | a[i] nxtscore = score + abs(now - nxt) if not (nxt in dp[i+1]) or dp[i+1][nxt] < nxtscore: dp[i+1][nxt] = nxtscore print(max(dp[n].values()))