#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
int a[maxn * 10 + 1];
int main(void) {
  int n, x;
  scanf("%d%d", &n, &x);
  {
    memset(a, 0, sizeof(a));
    int num = 0, lx = (x / 4) * 4, ux = lx + 4;
    if (x == 0 && n == 2) {
      printf("NO\n");
      return 0;
    }
    if (x == 0) {
      switch (n % 4) {
        case 0:
          break;
        case 1:
          a[0] = 1;
          num++;
          break;
        case 2:
          a[1] = a[2] = a[4] = a[5] = a[8] = a[10] = 1;
          num += 6;
          break;
        case 3:
          a[1] = a[2] = a[3] = 1;
          num += 3;
          break;
      }
    } else if (x == 1) {
      switch (n % 4) {
        case 0:
          a[1] = a[2] = a[8] = a[10] = 1;
          num += 4;
          break;
        case 1:
          a[1] = 1;
          num++;
          break;
        case 2:
          a[0] = a[1] = 1;
          num += 2;
          break;
        case 3:
          a[0] = a[2] = a[3] = 1;
          num += 3;
          break;
      }
    } else if (x == 2) {
      switch (n % 4) {
        case 0:
          a[1] = a[2] = a[4] = a[5] = 1;
          num += 4;
          break;
        case 1:
          a[2] = 1;
          num++;
          break;
        case 2:
          a[0] = a[2] = 1;
          num += 2;
          break;
        case 3:
          a[0] = a[1] = a[3] = 1;
          num += 3;
          break;
      }
    } else if (x == 3) {
      switch (n % 4) {
        case 0:
          a[1] = a[3] = a[4] = a[5] = 1;
          num += 4;
          break;
        case 1:
          a[3] = 1;
          num++;
          break;
        case 2:
          a[0] = a[3] = 1;
          num += 2;
          break;
        case 3:
          a[0] = a[1] = a[2] = 1;
          num += 3;
          break;
      }
    } else {
      switch (n % 4) {
        case 0:
          a[x] = a[1] = a[2] = a[3] = 1;
          num += 4;
          break;
        case 1:
          a[x] = 1;
          num++;
          break;
        case 2:
          a[x] = a[0] = 1;
          num += 2;
          break;
        case 3:
          a[x + ((x & 1) ? -1 : 1)] = a[1] = a[0] = 1;
          num += 3;
          break;
      }
    }
    for (int i = 200000; i < lx; i++) {
      if (num >= n) break;
      a[i] = 1;
      num++;
    }
    for (int i = max(ux, 200000); i <= 1000000; i++) {
      if (num >= n) break;
      a[i] = 1;
      num++;
    }
    int ans = 0;
    for (int i = 0; i <= 1000000; i++)
      if (a[i]) ans ^= i;
    if (ans != x) printf("??? ans=%d\n", ans);
    printf("YES\n");
    for (int i = 0; i <= 1000000; i++)
      if (a[i]) printf("%d ", i);
    printf("\n");
  }
  return 0;
}
