#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int INF = 2e9 + 7;
const int MOD = 1e6 + 3;
const long long LINF = 1e17 + 7;
const double Pi = acos(-1.);
const double EPS = 1e-8;
int n, id, top, sta[N], ls[N], rs[N];
char str[N], val[N];
struct Node {
  bool g0, g1, ge, gn;
  void clear() { g0 = g1 = ge = gn = false; }
  void out() { printf("%d %d %d %d\n", g0, g1, ge, gn); }
} f[N];
void dfs(int u, int p = -1) {
  f[u].clear();
  if (val[u] == '0') {
    f[u].g0 = true;
    return;
  }
  if (val[u] == '1') {
    f[u].g1 = true;
    return;
  }
  if (val[u] == '?') {
    f[u].ge = true;
    return;
  }
  int l = ls[u], r = rs[u];
  dfs(l), dfs(r);
  for (int i = 0; i < 2; ++i) {
    if (val[u] == '&') {
      f[u].g0 |= f[l].g0 || (f[l].ge && f[r].ge) || (f[l].ge && f[r].gn);
      f[u].g1 |= f[l].g1 && f[r].g1;
      f[u].ge |= (f[l].g1 && f[r].ge) || (f[l].ge && f[r].ge);
      f[u].gn |= (f[l].g1 && f[r].gn) || (f[l].gn && f[r].gn);
    } else if (val[u] == '|') {
      f[u].g0 |= f[l].g0 && f[r].g0;
      f[u].g1 |= f[l].g1 || (f[l].ge && f[r].ge) || (f[l].ge && f[r].gn);
      f[u].ge |= (f[l].g0 && f[r].ge) || (f[l].ge && f[r].ge);
      f[u].gn |= (f[l].g0 && f[r].gn) || (f[l].gn && f[r].gn);
    } else {
      f[u].g0 |= (f[l].g0 && f[r].g0) || (f[l].g1 && f[r].g1) ||
                 (f[l].ge && f[r].ge) || (f[l].gn && f[r].gn);
      f[u].g1 |= (f[l].g0 && f[r].g1) || (f[l].ge && f[r].ge) ||
                 (f[l].ge && f[r].gn) || (f[l].gn && f[r].gn);
      f[u].ge |= (f[l].g0 && f[r].ge) || (f[l].g1 && f[r].gn);
      f[u].gn |= (f[l].g0 && f[r].gn) || (f[l].g1 && f[r].ge);
    }
    swap(l, r);
  }
}
int main() {
  scanf("%d %s", &n, str);
  for (int i = 0; str[i]; ++i)
    if (str[i] == '(') {
      sta[++top] = id++;
    } else if (str[i] == ')') {
      if (top > 1) {
        int x = sta[top - 1];
        !ls[x] ? ls[x] = sta[top] : rs[x] = sta[top];
      }
      --top;
    } else if (str[i] == '0' || str[i] == '1' || str[i] == '?') {
      val[id] = str[i];
      if (top > 0) {
        int x = sta[top];
        !ls[x] ? ls[x] = id : rs[x] = id;
      }
      ++id;
    } else {
      val[sta[top]] = str[i];
    }
  dfs(0);
  if (f[0].ge || f[0].gn) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}
