#include <bits/stdc++.h>
const int MAXN = 1 << 20;
char s[MAXN];
int pos[MAXN];
int f[MAXN];
int stk[MAXN], top;
int ID[2][2] = {{4, 8}, {16, 32}};
int ff(int a, char key, int b) {
  if (key == '&') return a & b;
  if (key == '|') return a | b;
  if (key == '^') return a ^ b;
}
int cal(int a, char key, int b) {
  int Bit = 0;
  for (int i1 = 0; i1 < 2; i1++)
    if (a & (1 << i1))
      for (int i2 = 0; i2 < 2; i2++)
        if (b & (1 << i2)) Bit |= (1 << ff(i1, key, i2));
  for (int x1 = 0; x1 < 2; x1++)
    for (int y1 = 0; y1 < 2; y1++)
      if (a & ID[x1][y1])
        for (int x2 = 0; x2 < 2; x2++)
          for (int y2 = 0; y2 < 2; y2++)
            if (b & ID[x2][y2]) {
              int x3 = ff(x1, key, x2);
              int y3 = ff(y1, key, y2);
              Bit |= ID[x3][y3];
            }
  return Bit;
}
bool check(int a) {
  if ((a & 3) != 3) return false;
  return (a & ID[0][1]) || (a & ID[1][0]);
}
int main() {
  int i, j, n;
  scanf("%d%s", &n, s);
  n = strlen(s);
  for (i = 0; i < n; i++) {
    if (s[i] == '(')
      stk[++top] = i;
    else if (s[i] == ')') {
      int p = stk[top--];
      pos[p] = i;
      pos[i] = p;
    }
  }
  for (i = n - 1; i >= 0; i--) {
    if (s[i] == '(') {
      int L = i + 1;
      int p = (s[i + 1] == '(') ? pos[i + 1] : i + 1;
      p++;
      int R = p + 1;
      f[i] = cal(f[L], s[p], f[R]);
    } else if (s[i] == '0')
      f[i] = ID[0][0] | 1;
    else if (s[i] == '1')
      f[i] = ID[1][1] | 2;
    else if (s[i] == '?')
      f[i] = ID[0][1] | ID[1][0] | 3;
  }
  if (check(f[0]))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
