#include <bits/stdc++.h>
using namespace std;
char formula[1000003];
int fcEval(char opchar, int fcA, int fcB) {
  int fcRet = 0;
  for (int apair = 0; apair < 4; apair++) {
    if (((fcA >> apair) & 1) == 1) {
      for (int bpair = 0; bpair < 4; bpair++) {
        if (((fcB >> bpair) & 1) == 1) {
          int rpair = -1;
          switch (opchar) {
            case '&':
              rpair = apair & bpair;
              break;
            case '|':
              rpair = apair | bpair;
              break;
            case '^':
              rpair = apair ^ bpair;
              break;
          }
          fcRet |= (1 << rpair);
        }
      }
    }
  }
  return fcRet;
}
int fcParse(int start, int& end) {
  if (formula[start] == '0') {
    end = start + 1;
    return 1;
  }
  if (formula[start] == '1') {
    end = start + 1;
    return 8;
  }
  if (formula[start] == '?') {
    end = start + 1;
    return 6;
  }
  if (formula[start] == '(') {
    int opi;
    int fcA = fcParse(start + 1, opi);
    char opchar = formula[opi];
    int bend;
    int fcB = fcParse(opi + 1, bend);
    end = bend + 1;
    int evalue = fcEval(opchar, fcA, fcB);
    return evalue;
  }
  return -1;
}
int main() {
  int n;
  scanf("%d\n", &n);
  fgets(formula, 1000001, stdin);
  int waste;
  if ((fcParse(0, waste) & 2) != 0) {
    printf("YES");
  } else {
    printf("NO");
  }
}
