#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, m, nstk;
char equ[N];
int opr[N], stk[N];
inline bool IfOper(const char& c) { return c == '|' || c == '&' || c == '^'; }
inline int Number(const char& c) { return c == '?' ? 4 : c == '0' ? 1 : 2; }
int Solve(const int& le, const int& ri) {
  if (opr[le]) {
    int resL = Solve(le + 1, opr[le] - 1), resR = Solve(opr[le] + 1, ri - 1);
    bool l0 = resL & 1, l1 = resL >> 1 & 1, l2 = resL >> 2 & 1, r0 = resR & 1,
         r1 = resR >> 1 & 1, r2 = resR >> 2 & 1, t0 = 0, t1 = 0, t2 = 0;
    switch (equ[opr[le]]) {
      case '&': {
        t0 = l0 | r0 | (l2 & r2);
        t1 = l1 & r1;
        t2 = (l2 & r2) | (l1 & r2) | (l2 & r1);
        break;
      }
      case '|': {
        t0 = l0 & r0;
        t1 = l1 | r1 | (l2 & r2);
        t2 = (l2 & r2) | (l0 & r2) | (l2 & r0);
        break;
      }
      case '^': {
        t0 = (l0 & r0) | (l1 & r1) | (l2 & r2);
        t1 = (l0 & r1) | (l1 & r0) | (l2 & r2);
        t2 = ((l0 | l1) & r2) | (l2 & (r0 | r1));
        break;
      }
    }
    return t0 | (t1 << 1) | (t2 << 2);
  } else
    return Number(equ[le]);
}
int main() {
  scanf("%d%s", &n, equ + 1);
  m = (int)strlen(equ + 1);
  if (m == 1) {
    printf("%s\n", equ[1] == '?' ? "YES" : "NO");
    return 0;
  }
  for (int i = 1; i <= m; i++) switch (equ[i]) {
      case '(': {
        stk[++nstk] = i;
        break;
      }
      case ')': {
        nstk--;
        break;
      }
      default: {
        if (IfOper(equ[i])) opr[stk[nstk]] = i;
        break;
      }
    }
  printf("%s\n", (Solve(1, m) >> 2 & 1) ? "YES" : "NO");
  return 0;
}
