#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
struct node {
  int left, right, par;
  char val;
};
node tree[1000000];
char func[1000000][1 << 4];
int n, m;
string s;
void get(int v) {
  char val = tree[v].val;
  if (tree[v].left == 0) {
    if (val == '1') {
      func[v][0b1111] = 1;
    } else if (val == '0') {
      func[v][0b0000] = 1;
    } else {
      func[v][0b0101] = 1;
      func[v][0b0011] = 1;
    }
  } else {
    get(tree[v].left);
    get(tree[v].right);
    for (int ml = 0; ml < (1 << 4); ml++) {
      if (func[tree[v].left][ml]) {
        for (int mr = 0; mr < (1 << 4); mr++) {
          if (func[tree[v].right][mr]) {
            int m;
            if (val == '&') {
              m = ml & mr;
            } else if (val == '|') {
              m = ml | mr;
            } else {
              m = ml ^ mr;
            }
            func[v][m] = 1;
          }
        }
      }
    }
  }
}
bool bit(int m, int i) { return m & (1 << i); }
void solve() {
  m = s.size();
  if (s.size() == 1) {
    cout << (s[0] == '?' ? "YES" : "NO") << endl;
    return;
  }
  memset(tree, 0, sizeof(tree));
  memset(func, 0, sizeof(func));
  int ptr = 0, next = 0;
  for (int i = (s[0] == '('); i < m - (s[0] == '('); i++) {
    bool isVal = s[i] == '1' || s[i] == '0' || s[i] == '?';
    bool isOp = s[i] == '^' || s[i] == '|' || s[i] == '&';
    if (s[i] == '(' || isVal) {
      if (tree[ptr].left == 0) {
        tree[ptr].left = ++next;
      } else {
        tree[ptr].right = ++next;
      }
      tree[next].par = ptr;
      ptr = next;
    }
    if (isVal || isOp) {
      tree[ptr].val = s[i];
    }
    if (isVal || s[i] == ')') {
      ptr = tree[ptr].par;
    }
  }
  get(0);
  for (int m = 0; m < (1 << 4); m++) {
    if ((bit(m, 0) ^ bit(m, 3) || bit(m, 1) ^ bit(m, 2)) && func[0][m]) {
      cout << "YES" << endl;
      return;
    }
  }
  cout << "NO" << endl;
}
int main() {
  while (cin >> n >> s) {
    solve();
  }
}
