#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, nxt;
} e[1000005];
int f[1000005];
int head[1000005], cnt;
int n, l, tot;
char s[1000005];
stack<int> st;
bool dp[1000005][3];
void link(int s, int t) {
  e[++cnt] = (edge)<% t, head[s] %>;
  head[s] = cnt;
}
void dfs(int x) {
  int lson = -1, rson = -1;
  for (int i = head[x]; i; i = e[i].nxt)
    if (~lson)
      rson = e[i].to;
    else
      lson = e[i].to;
  if (lson == -1) {
    dp[x][f[x]] = 1;
    return;
  }
  dfs(lson), dfs(rson);
  if (f[x] == 0) {
    dp[x][0] |= dp[lson][0] & dp[rson][0];
    dp[x][1] |= dp[lson][1] | dp[rson][1];
    dp[x][1] |= dp[lson][2] & dp[rson][2];
    dp[x][2] |= dp[lson][2] & dp[rson][2];
    dp[x][2] |= dp[lson][2] & dp[rson][0];
    dp[x][2] |= dp[rson][2] & dp[lson][0];
  } else if (f[x] == 1) {
    dp[x][0] |= dp[lson][0] | dp[rson][0];
    dp[x][0] |= dp[lson][2] & dp[rson][2];
    dp[x][1] |= dp[lson][1] & dp[rson][1];
    dp[x][2] |= dp[lson][2] & dp[rson][2];
    dp[x][2] |= dp[lson][2] & dp[rson][1];
    dp[x][2] |= dp[rson][2] & dp[lson][1];
  } else {
    dp[x][0] |= dp[lson][0] & dp[rson][0];
    dp[x][0] |= dp[lson][1] & dp[rson][1];
    dp[x][0] |= dp[lson][2] & dp[rson][2];
    dp[x][1] |= dp[lson][0] & dp[rson][1];
    dp[x][1] |= dp[lson][1] & dp[rson][0];
    dp[x][1] |= dp[lson][2] & dp[rson][2];
    dp[x][2] |= dp[lson][2] & (dp[rson][0] | dp[rson][1]);
    dp[x][2] |= dp[rson][2] & (dp[lson][0] | dp[lson][1]);
  }
}
int main() {
  scanf("%d%s", &n, s + 1), l = strlen(s + 1);
  for (int i = 1; i <= l; i++) {
    if (s[i] == '(')
      st.push(++tot);
    else if (s[i] == ')') {
      int k = st.top();
      st.pop();
      if (!st.empty()) link(st.top(), k);
    } else if (s[i] == '?' || isdigit(s[i])) {
      f[++tot] = s[i] == '?' ? 2 : s[i] - '0';
      if (!st.empty()) link(st.top(), tot);
    } else {
      if (s[i] == '|') f[st.top()] = 0;
      if (s[i] == '&') f[st.top()] = 1;
      if (s[i] == '^') f[st.top()] = 2;
    }
  }
  dfs(1);
  if (dp[1][2])
    puts("YES");
  else
    puts("NO");
  return 0;
}
