#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, x;
  while (~scanf("%lld%lld", &n, &x)) {
    int acm = 0;
    if (n == 1) {
      printf("YES\n%lld\n", x);
    } else if (n == 2 && !x) {
      printf("NO\n");
    } else {
      long long int k = 1 << 17, k2 = 1 << 18;
      long long int m = 0;
      for (long long int i = 1; i <= n - 2; i++) {
        m = m ^ i;
      }
      if (m != x) {
        m = m ^ k;
        x = x ^ k;
      } else {
        m = m ^ k;
        x ^= k;
        acm = 1;
      }
      printf("YES\n");
      for (long long int i = 1; i <= n - 3; i++) printf("%lld ", i);
      if (acm) {
        printf("%lld ", (n - 2) ^ k2);
        m ^= k2;
      } else if (n > 2) {
        printf("%lld ", n - 2);
      }
      if (((n - 2) ^ k2) == m) {
        m ^= 1 << 19;
        x ^= 1 << 19;
      }
      printf("%lld %lld\n", m, x);
    }
  }
}
