#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T abs1(T a) {
  return a < 0 ? -a : a;
}
template <class T>
inline T max1(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T min1(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline T gcd1(T a, T b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd1(b, a % b);
}
const int maxn = 1000010;
char str[maxn];
int l;
int corr[maxn];
int st[maxn], lst;
int justdoit(int st, int en);
inline int getnext(int &i) {
  if (str[i] == '(') {
    int st1 = i + 1;
    int en1 = corr[i];
    i = en1 + 1;
    return justdoit(st1, en1);
  } else {
    i++;
    if (str[i - 1] == '?') return 4;
    if (str[i - 1] == '0') return 1;
    if (str[i - 1] == '1') return 2;
  }
  return 0;
}
int justdoit(int st, int en) {
  int i = st;
  int rans = getnext(i);
  for (; i < en;) {
    char fu = str[i];
    i++;
    int temp = getnext(i);
    int rans1 = 0;
    if (fu == '|') {
      if (((rans & 1) && (temp & 1))) rans1 |= 1;
      if ((rans & 2) || (temp & 2) || ((rans & 4) && (temp & 4))) rans1 |= 2;
      if (((rans & 4) && !(temp == 2)) || ((temp & 4) && !(rans == 2)))
        rans1 |= 4;
    } else if (fu == '&') {
      if ((rans & 1) || (temp & 1) || ((rans & 4) && (temp & 4))) rans1 |= 1;
      if (((rans & 2) && (temp & 2))) rans1 |= 2;
      if (((rans & 4) && !(temp == 1)) || ((temp & 4) && !(rans == 1)))
        rans1 |= 4;
    } else if (fu == '^') {
      if (((rans & 1) && (temp & 1)) || ((rans & 2) && (temp & 2)) ||
          ((rans & 4) && (temp & 4)))
        rans1 |= 1;
      if (((rans & 2) && (temp & 1)) || ((rans & 1) && (temp & 2)) ||
          ((rans & 4) && (temp & 4)))
        rans1 |= 2;
      if (((rans & 4) && ((temp & 1) || (temp & 2))) ||
          ((temp & 4) && ((rans & 1) || (rans & 2))))
        rans1 |= 4;
    }
    rans = rans1;
  }
  return rans;
}
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", str);
  l = strlen(str);
  for (int i = 0; i < l; i++) {
    if (str[i] == '(')
      st[lst++] = i;
    else if (str[i] == ')') {
      corr[st[lst - 1]] = i;
      lst--;
    }
  }
  if (justdoit(0, l) & 4)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
