#include <bits/stdc++.h>
using namespace std;
int n, match[1000010], Stack[1000010], tot;
bool f[1000010][2][2];
char s[1000010];
int main() {
  cin >> n >> s;
  n = strlen(s);
  for (int i = 0; i < n; i++)
    if (s[i] == '(')
      Stack[++tot] = i;
    else if (s[i] == ')') {
      match[i] = Stack[tot];
      match[Stack[tot--]] = i;
    }
  for (int i = 0; i < n; i++) {
    switch (s[i]) {
      case '0':
        f[i][0][0] = 1;
        break;
      case '1':
        f[i][1][1] = 1;
        break;
      case '?':
        f[i][0][1] = f[i][1][0] = 1;
        break;
      case ')':
        int P_oper = s[i - 1] == ')' ? (match[i - 1] - 1) : (i - 2);
        char oper = s[P_oper];
        int P_left = P_oper - 1;
        int P_right = i - 1;
        for (int p = 0; p < 2; p++)
          for (int q = 0; q < 2; q++)
            if (f[P_left][p][q])
              for (int x = 0; x < 2; x++)
                for (int y = 0; y < 2; y++)
                  if (f[P_right][x][y]) {
                    switch (oper) {
                      case '&':
                        f[i][p & x][q & y] = 1;
                        break;
                      case '|':
                        f[i][p | x][q | y] = 1;
                        break;
                      case '^':
                        f[i][p ^ x][q ^ y] = 1;
                    }
                  }
    }
  }
  if (f[n - 1][0][1] || f[n - 1][1][0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
