#include <bits/stdc++.h>
const int fin = 0, maxn = 1000010;
int n;
char s[maxn];
int left[maxn], st[maxn];
struct rec {
  bool a[3];
  rec() {}
  rec(bool x, bool y, bool z) { a[0] = x, a[1] = y, a[2] = z; }
  const bool& operator[](const int& x) { return a[x]; }
};
inline rec sol(int l, int r) {
  if (l == r)
    if (s[l] == '0')
      return rec(1, 0, 0);
    else if (s[l] == '1')
      return rec(0, 1, 0);
    else if (s[l] == '?')
      return rec(0, 0, 1);
  int p = s[r - 1] == ')' ? left[r - 1] - 1 : r - 2;
  rec a = sol(l + 1, p - 1), b = sol(p + 1, r - 1);
  if (s[p] == '&')
    return rec(a[0] || b[0] || a[2] && b[2], a[1] && b[1],
               a[1] && b[2] || a[2] && b[1] || a[2] && b[2]);
  else if (s[p] == '|')
    return rec(a[0] && b[0], a[1] || b[1] || a[2] && b[2],
               a[0] && b[2] || a[2] && b[0] || a[2] && b[2]);
  else
    return rec(a[0] && b[0] || a[1] && b[1] || a[2] && b[2],
               a[0] && b[1] || a[1] && b[0] || a[2] && b[2],
               a[2] && (b[0] || b[1]) || (a[0] || a[1]) && b[2]);
}
int main() {
  if (fin) {
    freopen("t.in", "r", stdin);
    freopen("t.out", "w", stdout);
  }
  int i;
  scanf("%*d\n%s", s), n = strlen(s);
  for (i = 0; i < n; ++i)
    if (s[i] == '(')
      st[++st[0]] = i;
    else if (s[i] == ')')
      left[i] = st[st[0]--];
  rec ans = sol(0, n - 1);
  puts(ans[2] ? "YES" : "NO");
  return 0;
}
