#include <bits/stdc++.h>
using namespace std;
using namespace rel_ops;
const double PI = acos((double)-1);
int ts, ts2, ts3, ts4;
int n, m;
long long gcd(long long x, long long y) {
  long long t;
  for (; y != 0;) {
    t = x % y;
    x = y;
    y = t;
  }
  return x;
}
int calc(int a, int b, char opt) {
  if (opt == '|') return a | b;
  if (opt == '&') return a & b;
  if (opt == '^') return a ^ b;
}
char st[1000012], s[1000012];
int f[1000012][2][2];
int main() {
  int len, slen, i, j, k, l, o;
  scanf("%*d%s", s);
  len = strlen(s);
  for (i = 0, slen = -1; i < len; ++i) {
    if (s[i] == ')') {
      int f2[2][2] = {0};
      char ch = st[slen - 1];
      for (j = 0; j < 2; ++j)
        for (k = 0; k < 2; ++k)
          if (f[slen][j][k])
            for (l = 0; l < 2; ++l)
              for (o = 0; o < 2; ++o)
                if (f[slen - 2][l][o]) f2[calc(j, l, ch)][calc(k, o, ch)] = 1;
      slen -= 2;
      for (j = 0; j < 2; ++j)
        for (k = 0; k < 2; ++k) f[slen][j][k] = f2[j][k];
    } else if (s[i] == '0') {
      memset(f[++slen], 0, sizeof(f[0]));
      f[slen][0][0] = 1;
    } else if (s[i] == '1') {
      memset(f[++slen], 0, sizeof(f[0]));
      f[slen][1][1] = 1;
    } else if (s[i] == '?') {
      ++slen;
      f[slen][0][0] = f[slen][1][1] = 0;
      f[slen][0][1] = f[slen][1][0] = 1;
    } else if (s[i] != '(')
      st[++slen] = s[i];
  }
  if (f[0][0][1])
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
