#include <bits/stdc++.h>
using std::vector;
int AND_TABLE[4][4] = {{1, 8, 1, 8}, {8, 2, 2, 8}, {1, 2, 4, 8}, {8, 8, 8, 8}};
int OR_TABLE[4][4] = {{1, 4, 4, 1}, {4, 2, 4, 2}, {4, 4, 4, 4}, {1, 2, 4, 8}};
int XOR_TABLE[4][4] = {{8, 4, 2, 1}, {4, 8, 1, 2}, {2, 1, 8, 4}, {1, 2, 4, 8}};
struct node {
  char type;
  node *left, *right;
  int reduce() {
    if (type == '0') {
      return 8;
    }
    if (type == '1') {
      return 4;
    }
    if (type == '?') {
      return 1 | 2;
    }
    int l = left->reduce(), r = right->reduce(), v = 0;
    int(*res)[4][4];
    if (type == '&') {
      res = &AND_TABLE;
    }
    if (type == '|') {
      res = &OR_TABLE;
    }
    if (type == '^') {
      res = &XOR_TABLE;
    }
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if ((l & (1 << i)) && (r & (1 << j))) {
          v |= (*res)[i][j];
        }
      }
    }
    return v;
  }
};
char data[1000000];
char *iter;
node *parse() {
  node *n = new node();
  if (*iter == '(') {
    iter++;
    n->left = parse();
    n->type = *iter;
    iter++;
    n->right = parse();
    iter++;
  } else {
    n->type = *iter;
    iter++;
  }
  return n;
}
void dump(node n, int ind) {
  for (int i = 0; i < ind * 4; i++) {
    printf(" ");
  }
  printf("%c\n", n.type);
  if (n.type == '&' || n.type == '|' || n.type == '^') {
    dump(*n.left, ind + 1);
    dump(*n.right, ind + 1);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", data);
  iter = data;
  node *nd = parse();
  printf("%s\n", nd->reduce() & (1 | 2) ? "YES" : "NO");
}
