#include <bits/stdc++.h>
using namespace std;
const int u = 1000010;
char s[u], ch;
int L[u], R[u], st[u];
bool f[u][2][2];
int n, m, i, p, l, r, a, b, c, d;
int main() {
  cin >> n;
  scanf("%s", s + 1);
  m = strlen(s + 1);
  for (i = 1; i <= m; i++)
    if (s[i] == '(')
      st[++p] = i;
    else if (s[i] == ')')
      R[st[p]] = i, L[i] = st[p--];
    else if (s[i] == '0')
      f[i][0][0] = 1;
    else if (s[i] == '1')
      f[i][1][1] = 1;
    else
      f[i][0][1] = f[i][1][0] = 1;
  for (i = 1; i <= m; i++)
    if (s[i] == ')') {
      if (s[i - 1] != ')')
        ch = s[i - 2], l = i - 3, r = i - 1;
      else
        ch = s[L[i - 1] - 1], l = L[i - 1] - 2, r = i - 1;
      for (a = 0; a < 2; a++)
        for (b = 0; b < 2; b++)
          if (f[l][a][b])
            for (c = 0; c < 2; c++)
              for (d = 0; d < 2; d++)
                if (f[r][c][d])
                  if (ch == '&')
                    f[i][a & c][b & d] = 1;
                  else if (ch == '|')
                    f[i][a | c][b | d] = 1;
                  else if (ch == '^')
                    f[i][a ^ c][b ^ d] = 1;
    }
  if (f[m][0][1] || f[m][1][0])
    puts("YES");
  else
    puts("NO");
  return 0;
}
