#include <bits/stdc++.h>
int n, x, num, a[1000001], vis[1000001];
bool dfs(int now, int p) {
  if (now > 1e6) return false;
  if (num == n - 1) {
    if (vis[p] || p > 1e6) return false;
    a[++num] = p;
    return true;
  }
  a[++num] = now, vis[now] = 1;
  if (dfs(now + 1, p ^ now)) return true;
  vis[now] = 0, --num;
  if (dfs(now + 1, p)) return true;
  return false;
}
int main() {
  scanf("%d %d", &n, &x);
  if (n == 2 && x == 0)
    printf("NO\n");
  else {
    printf("YES\n");
    dfs(1, x);
    for (int i = 1; i <= n; ++i) printf("%d ", a[i]);
  }
  return 0;
}
