#include <bits/stdc++.h>
char s[1000010];
int ne[1000010], st[1000010], st_n;
struct DP {
  int can[2][2];
  int val0, val1;
};
DP solve(int l, int r) {
  DP res;
  memset(&res, 0, sizeof(res));
  if (l == r) {
    if (s[l] == '1') {
      res.val0 = 1;
      res.val1 = 1;
      res.can[0][0] = 0;
      res.can[1][1] = 1;
      res.can[0][1] = res.can[1][0] = 0;
    } else if (s[l] == '0') {
      res.val0 = 0;
      res.val1 = 0;
      res.can[0][0] = 1;
      res.can[1][1] = 0;
      res.can[0][1] = res.can[1][0] = 00;
    } else if (s[l] == '?') {
      res.val0 = 0;
      res.val1 = 1;
      res.can[0][0] = 0;
      res.can[1][1] = 0;
      res.can[0][1] = res.can[1][0] = 1;
    }
  } else {
    int i = ne[l + 1] + 1;
    DP a = solve(l + 1, i - 1), b = solve(i + 1, r - 1);
    if (s[i] == '&') {
      res.val0 = a.val0 & b.val0;
      res.val1 = a.val1 & b.val1;
      for (int a1 = 0; a1 < 2; a1++) {
        for (int a2 = 0; a2 < 2; a2++) {
          for (int b1 = 0; b1 < 2; b1++) {
            for (int b2 = 0; b2 < 2; b2++) {
              if (a.can[a1][a2] && b.can[b1][b2]) {
                res.can[a1 & b1][a2 & b2] = 1;
              }
            }
          }
        }
      }
    } else if (s[i] == '|') {
      res.val0 = a.val0 | b.val0;
      res.val1 = a.val1 | b.val1;
      for (int a1 = 0; a1 < 2; a1++) {
        for (int a2 = 0; a2 < 2; a2++) {
          for (int b1 = 0; b1 < 2; b1++) {
            for (int b2 = 0; b2 < 2; b2++) {
              if (a.can[a1][a2] && b.can[b1][b2]) {
                res.can[a1 | b1][a2 | b2] = 1;
              }
            }
          }
        }
      }
    } else if (s[i] == '^') {
      res.val0 = a.val0 ^ b.val0;
      res.val1 = a.val1 ^ b.val1;
      for (int a1 = 0; a1 < 2; a1++) {
        for (int a2 = 0; a2 < 2; a2++) {
          for (int b1 = 0; b1 < 2; b1++) {
            for (int b2 = 0; b2 < 2; b2++) {
              if (a.can[a1][a2] && b.can[b1][b2]) {
                res.can[a1 ^ b1][a2 ^ b2] = 1;
              }
            }
          }
        }
      }
    }
  }
  return res;
}
int main(void) {
  int n;
  scanf("%d\n", &n);
  gets(s);
  int sn;
  sn = strlen(s);
  for (int i = 0; i < sn; i++) {
    ne[i] = i;
    if (s[i] == '(') {
      st[st_n++] = i;
    } else if (s[i] == ')') {
      assert(st_n > 0);
      st_n--;
      ne[st[st_n]] = i;
    }
  }
  DP res = solve(0, sn - 1);
  printf((res.val0 != res.val1 || res.can[0][1] || res.can[1][0]) ? "YES\n"
                                                                  : "NO\n");
  return 0;
}
