#include <bits/stdc++.h>
using namespace std;
const int N(1000010);
struct TState {
  bool b[4];
};
int t;
stack<int> st;
TState f[2 * N];
int mat[N];
char s[N];
void solve(int l, int r) {
  if (l != r && mat[l] == r) {
    solve(l + 1, r - 1);
    return;
  }
  int now = ++t;
  if (l == r) {
    if (s[l] == '0')
      f[now].b[0] = true;
    else if (s[l] == '1')
      f[now].b[3] = true;
    else
      f[now].b[1] = f[now].b[2] = true;
  } else {
    int a = t + 1;
    solve(l, mat[l]);
    int b = t + 1;
    solve(mat[l] + 2, r);
    for (int x = int(0); x < int(4); ++x)
      for (int y = int(0); y < int(4); ++y)
        if (f[a].b[x] && f[b].b[y]) {
          if (s[mat[l] + 1] == '&')
            f[now].b[x & y] = true;
          else if (s[mat[l] + 1] == '|')
            f[now].b[x | y] = true;
          else
            f[now].b[x ^ y] = true;
        }
  }
}
int main() {
  scanf("%*d%s", s);
  int m = strlen(s);
  for (int i = int(0); i < int(m); ++i) {
    mat[i] = i;
    if (s[i] == '(')
      st.push(i);
    else if (s[i] == ')') {
      mat[st.top()] = i;
      st.pop();
    }
  }
  solve(0, m - 1);
  if (f[1].b[1] || f[1].b[2])
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
