import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int t = sc.nextInt(); ArrayList> dp = new ArrayList<>(); for (int i = 0; i <= n; i++) { dp.add(new HashMap<>()); } dp.get(0).put(t, 0L); for (int i = 1; i <= n; i++) { int a = sc.nextInt(); for (Map.Entry entry : dp.get(i - 1).entrySet()) { int next1 = (entry.getKey() & a); long value1 = entry.getValue() + Math.abs(next1 - entry.getKey()); if (!dp.get(i).containsKey(next1) || dp.get(i).get(next1) < value1) { dp.get(i).put(next1, value1); } int next2 = (entry.getKey() | a); long value2 = entry.getValue() + Math.abs(next2 - entry.getKey()); if (!dp.get(i).containsKey(next2) || dp.get(i).get(next2) < value2) { dp.get(i).put(next2, value2); } } } long max = 0; for (long x : dp.get(n).values()) { max = Math.max(max, x); } System.out.println(max); } }