#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 10;
char s[N];
struct Node {
  char c;
  Node *left, *right;
  bool d[2][2];
};
Node pool[N], *last = pool;
void parse(Node *&cur, char *s) {
  if (s[0] == '?' || s[0] == '0' || s[0] == '1') {
    cur = last++;
    cur->c = s[0];
    cur->left = cur->right = NULL;
    cur->d[0][0] = cur->d[0][1] = cur->d[1][0] = cur->d[1][1] = false;
    if (s[0] == '?') {
      cur->d[0][1] = cur->d[1][0] = true;
    } else {
      int x = s[0] - '0';
      cur->d[x][x] = true;
    }
    return;
  }
  int sum = 0, i;
  for (i = 1; s[i]; ++i) {
    if (s[i] == '(')
      ++sum;
    else if (s[i] == ')')
      --sum;
    else if (s[i] == '&' || s[i] == '|' || s[i] == '^') {
      if (sum == 0) break;
    }
  }
  cur = last++;
  cur->c = s[i];
  cur->d[0][0] = cur->d[0][1] = cur->d[1][0] = cur->d[1][1] = false;
  parse(cur->left, s + 1);
  parse(cur->right, s + i + 1);
  Node *left = cur->left;
  Node *right = cur->right;
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      if (left->d[i][j]) {
        for (int u = 0; u < 2; ++u) {
          for (int v = 0; v < 2; ++v) {
            if (right->d[u][v]) {
              if (cur->c == '&') {
                cur->d[i & u][j & v] = true;
              } else if (cur->c == '|') {
                cur->d[i | u][j | v] = true;
              } else if (cur->c == '^') {
                cur->d[i ^ u][j ^ v] = true;
              }
            }
          }
        }
      }
    }
  }
}
int main() {
  int n;
  scanf("%d%s", &n, s);
  Node *root;
  parse(root, s);
  puts(root->d[0][1] || root->d[1][0] ? "YES" : "NO");
  return 0;
}
