#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
const int INF = (1 << 18);
int n, x;
int num[maxn];
bool vis[maxn * 10];
int main() {
  ios::sync_with_stdio(false);
  while (scanf("%d%d", &n, &x) != EOF) {
    if (n == 1) {
      printf("YES\n%d\n", x);
      continue;
    }
    if (n == 2) {
      if (x == 0) {
        printf("NO\n");
      } else {
        printf("YES\n%d %d\n", 0, x);
      }
      continue;
    }
    memset(vis, 0, sizeof(vis));
    int Xor = x;
    for (int i = 1; i <= n; ++i) {
      num[i] = i;
      Xor ^= i;
    }
    num[n] ^= INF;
    num[n - 1] ^= INF;
    for (int i = 1; i <= n; ++i) {
      vis[num[i]] = true;
    }
    bool flag = false;
    for (int i = 1; i <= n; ++i) {
      int tmp = (Xor ^ num[i]);
      if (tmp <= 1000000 && (!vis[tmp] || tmp == num[i])) {
        Xor ^= num[i];
        num[i] = Xor;
        flag = true;
        break;
      }
    }
    if (flag) {
      printf("YES\n");
      for (int i = 1; i <= n; ++i) {
        if (i != 1) {
          printf(" ");
        }
        printf("%d", num[i]);
      }
      printf("\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
