#include <bits/stdc++.h>
using namespace std;
enum type { AND, OR, XOR, WILD, ONE, ZERO };
struct node;
struct node {
  type t;
  vector<node *> ch;
  int r, g[2];
  node() { r = g[0] = g[1] = -1; }
};
const int MAXN = 1000100;
char c[MAXN];
node *parse(int n) {
  vector<node *> st;
  for (int i = 0; i < (n); ++i) {
    if (c[i] == '(' || c[i] == '0' || c[i] == '1' || c[i] == '?') {
      st.push_back(new node);
    }
    if (c[i] == '(') {
      continue;
    }
    if (c[i] == '0') {
      st.back()->t = ZERO;
    } else if (c[i] == '1') {
      st.back()->t = ONE;
    } else if (c[i] == '?') {
      st.back()->t = WILD;
    } else if (c[i] == '|') {
      st.back()->t = OR;
    } else if (c[i] == '&') {
      st.back()->t = AND;
    } else if (c[i] == '^') {
      st.back()->t = XOR;
    }
    if (c[i] == ')' || c[i] == '0' || c[i] == '1' || c[i] == '?') {
      if (((int)((st).size())) == 1) {
        return st.back();
      } else {
        node *p = st.back();
        st.pop_back();
        st.back()->ch.push_back(p);
      }
    }
  }
  assert(0);
}
int G(node *v, int k);
int G(node *v);
int S(node *v, int k);
int R(node *v) {
  if (v->r != -1) {
    return v->r;
  }
  int &res = v->r;
  if (v->t == ZERO || v->t == ONE) {
    res = 0;
  } else if (v->t == WILD) {
    res = 1;
  } else {
    node *a = v->ch[0], *b = v->ch[1];
    if (v->t == AND) {
      res = (R(a) & S(b, 1)) | (R(b) & S(a, 1));
    } else if (v->t == OR) {
      res = (R(a) & S(b, 0)) | (R(b) & S(a, 0));
    } else {
      res = (R(a) & G(b)) | (R(b) & G(a));
    }
  }
  return res;
}
int G(node *v, int k) {
  if (v->g[k] != -1) {
    return v->g[k];
  }
  int &res = v->g[k];
  if (v->t == ONE) {
    res = (k == 1);
  } else if (v->t == ZERO) {
    res = (k == 0);
  } else if (v->t == WILD) {
    res = 0;
  } else {
    node *a = v->ch[0], *b = v->ch[1];
    if (v->t == AND) {
      if (k) {
        res = G(a, 1) & G(b, 1);
      } else {
        res = G(a, 0) | G(b, 0) | (R(a) & R(b));
      }
    } else if (v->t == OR) {
      if (k) {
        res = G(a, 1) | G(b, 1) | (R(a) & R(b));
      } else {
        res = G(a, 0) & G(b, 0);
      }
    } else if (v->t == XOR) {
      if (k) {
        res = (G(a, 0) & G(b, 1)) | (G(a, 1) & G(b, 0)) | (R(a) & R(b));
      } else {
        res = (G(a, 0) & G(b, 0)) | (G(a, 1) & G(b, 1)) | (R(a) & R(b));
      }
    }
  }
  return res;
}
int G(node *v) { return G(v, 0) | G(v, 1); }
int S(node *v, int k) { return R(v) | G(v, k); }
int main(void) {
  scanf("%*d%s", c);
  int n = strlen(c);
  puts(R(parse(n)) ? "YES" : "NO");
  return 0;
}
