#include <bits/stdc++.h>
using namespace std;
template <class T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <class T>
T min(T a, T b, T c, T d) {
  return min(a, min(b, min(c, d)));
}
template <class T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <class T>
T max(T a, T b, T c, T d) {
  return max(a, max(b, max(c, d)));
}
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
  return (a.first > b.first || (a.first == b.first && a.second >= b.second));
}
long long GCD(long long a, long long b) { return (a % b) ? GCD(b, a % b) : b; }
const string namePro = "tmp";
bool ck[1000007];
int main() {
  srand(time(NULL));
  int n, k;
  scanf("%d%d", &n, &k);
  vector<pair<int, int> > vc;
  int tmp = rand() % RAND_MAX + 1;
  for (int i = (1); i <= (1000000); ++i) {
    if ((tmp ^ i) > i) vc.push_back(make_pair(i, (tmp ^ i)));
  }
  if (n % 3 == 0 && k == 0) {
    set<int> st;
    for (int i = (0); i <= (1000000); ++i) {
      int k = rand() % RAND_MAX + 1;
      if ((i ^ k) > 1000000) continue;
      if (!ck[i] && !ck[k] && !ck[(i ^ k)] && i != k && i != (i ^ k) &&
          k != (i ^ k)) {
        ck[i] = ck[k] = ck[(i ^ k)] = 1;
        st.insert(i);
        st.insert(k);
        st.insert(i ^ k);
      }
      if ((int)st.size() == n) break;
    }
    puts("YES");
    for (__typeof(st.begin()) it = st.begin(); it != st.end(); ++it)
      cout << *it << " ";
    return 0;
  }
  int cnt = 0;
  bool check = 0;
  set<int> st;
  while (n > 2) {
    if (vc[cnt].first != k && vc[cnt].second != k && vc[cnt].first != tmp &&
        vc[cnt].second != tmp) {
      st.insert(vc[cnt].first);
      st.insert(vc[cnt].second);
      -- --n;
      check = !check;
    }
    ++cnt;
  }
  if (n == 2) {
    if (check) {
      st.insert(tmp);
      st.insert(k);
    } else {
      st.insert(tmp);
      st.insert((k ^ tmp));
    }
  } else {
    if (check)
      st.insert((k ^ tmp));
    else
      st.insert(k);
  }
  int ans = 0;
  for (__typeof(st.begin()) it = st.begin(); it != st.end(); ++it) ans ^= *it;
  if (ans == k) {
    puts("YES");
    for (__typeof(st.begin()) it = st.begin(); it != st.end(); ++it)
      cout << *it << " ";
  } else
    puts("NO");
  return 0;
}
