#include <bits/stdc++.h>
using namespace std;
int N;
char formula[1000005];
int dfs2(char*& pos) {
  char first = *(pos++);
  if (first == '0') return 1;
  if (first == '1') return 2;
  if (first == '?') return 3;
  assert(first == '(');
  int a = dfs2(pos);
  char op = *(pos++);
  int b = dfs2(pos);
  char paren = *(pos++);
  assert(paren == ')');
  int res = 0;
  for (int aa = 0; aa < 2; aa++)
    for (int bb = 0; bb < 2; bb++) {
      if ((a & (1 << aa)) && (b & (1 << bb))) {
        if (op == '|') res |= 1 << (aa | bb);
        if (op == '^') res |= 1 << (aa ^ bb);
        if (op == '&') res |= 1 << (aa & bb);
      }
    }
  return res;
}
int dfs(char*& pos) {
  char first = *(pos++);
  if (first == '0') return 1;
  if (first == '1') return 2;
  if (first == '?') return 4 | 8;
  assert(first == '(');
  int a = dfs(pos);
  char op = *(pos++);
  int b = dfs(pos);
  char paren = *(pos++);
  assert(paren == ')');
  int res = 0;
  for (int aa = 0; aa < 4; aa++)
    for (int bb = 0; bb < 4; bb++) {
      if ((a & (1 << aa)) && (b & (1 << bb))) {
        if (op == '|') {
          if (aa == bb)
            res |= 1 << aa;
          else if (aa == 1 || bb == 1)
            res |= 1 << 1;
          else if (aa + bb == 5)
            res |= 1 << 1;
          else
            res |= 1 << (aa + bb);
        }
        if (op == '^') {
          if (aa == bb)
            res |= 1 << 0;
          else if (aa == 0 || bb == 0)
            res |= 1 << (aa + bb);
          else if (aa == 1 || bb == 1)
            res |= 1 << (aa ^ bb);
          else
            res |= 1 << 1;
        }
        if (op == '&') {
          if (aa == bb)
            res |= 1 << aa;
          else if (aa == 0 || bb == 0)
            res |= 1 << 0;
          else if (aa + bb == 5)
            res |= 1 << 0;
          else
            res |= 1 << (aa + bb - 1);
        }
      }
    }
  return res;
}
int main() {
  cin >> N >> formula;
  char* pos = formula;
  int r = dfs2(pos);
  if (r == 3) {
    pos = formula;
    r = dfs(pos);
    if ((r & 4) || (r & 8)) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}
