#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static const int L = 233333;
  static char sxd[L], *sss = sxd, *ttt = sxd;
  if (sss == ttt) {
    ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
    if (sss == ttt) {
      return EOF;
    }
  }
  return *sss++;
}
inline char readalpha() {
  char c = gc();
  for (; !isalpha(c); c = gc())
    ;
  return c;
}
inline char readchar() {
  char c = gc();
  for (; c == ' '; c = gc())
    ;
  return c;
}
template <class T>
inline bool read(T& x) {
  bool flg = false;
  char c = gc();
  x = 0;
  for (; !isdigit(c); c = gc()) {
    if (c == '-') {
      flg = true;
    } else if (c == EOF) {
      return false;
    }
  }
  for (; isdigit(c); c = gc()) {
    x = (x << 1) + (x << 3) + (c ^ 48);
  }
  if (flg) {
    x = -x;
  }
  return true;
}
inline int getans(int x, int y, char z) {
  if (z == '^') {
    return x ^ y;
  } else if (z == '|') {
    return x | y;
  } else {
    return x & y;
  }
}
inline int dp() {
  char c = readchar();
  if (c == '1') {
    return 8;
  } else if (c == '0') {
    return 1;
  } else if (c == '?') {
    return 6;
  }
  int x = dp();
  c = readchar();
  int y = dp();
  int ans = 0;
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      if ((x & (1 << i)) && (y & (1 << j))) {
        ans |= 1 << getans(i, j, c);
      }
    }
  }
  c = readchar();
  return ans;
}
int main() {
  int n;
  read(n);
  puts(dp() & 6 ? "YES" : "NO");
  return 0;
}
