#include <bits/stdc++.h>
const int maxn = 1000005;
int f[maxn], pre[maxn], stk[maxn], dep;
int n;
int id[2][2] = {{4, 8}, {16, 32}};
int calc(int a, char op, int b) {
  if (op == '&') return (a & b);
  if (op == '|') return (a | b);
  if (op == '^') return (a ^ b);
}
int Gao(int a, char op, int b) {
  int i, j, x1, x2, y1, y2;
  int bit = 0;
  for (i = 0; i < 2; i++)
    if (a & (1 << i))
      for (j = 0; j < 2; j++)
        if (b & (1 << j)) bit |= (1 << (calc(i, op, j)));
  for (x1 = 0; x1 < 2; x1++)
    for (y1 = 0; y1 < 2; y1++)
      if (a & id[x1][y1])
        for (x2 = 0; x2 < 2; x2++)
          for (y2 = 0; y2 < 2; y2++)
            if (b & id[x2][y2]) {
              int _old = calc(x1, op, x2);
              int _new = calc(y1, op, y2);
              bit |= id[_old][_new];
            }
  return bit;
}
bool chark(int a) {
  if ((a & 3) != 3) return false;
  return (a & id[0][1]) || (a & id[1][0]);
}
int main() {
  int i, len;
  char s[maxn];
  while (scanf("%d", &n) != -1) {
    scanf("%s", s);
    len = strlen(s);
    dep = 0;
    for (i = 0; i < len; i++) {
      if (s[i] == '(')
        stk[dep++] = i;
      else if (s[i] == ')') {
        int tmp = stk[--dep];
        pre[tmp] = i;
        pre[i] = tmp;
      }
    }
    for (i = len - 1; i >= 0; i--) {
      if (s[i] == '(') {
        int L = i + 1;
        int p = s[i + 1] == '(' ? pre[i + 1] : i + 1;
        p++;
        int R = p + 1;
        f[i] = Gao(f[L], s[p], f[R]);
      } else if (s[i] == '0')
        f[i] = 1 | id[0][0];
      else if (s[i] == '1')
        f[i] = 2 | id[1][1];
      else if (s[i] == '?')
        f[i] = 3 | id[0][1] | id[1][0];
    }
    if (chark(f[0]))
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
