#include <bits/stdc++.h>
using namespace std;
inline long long pow(long long a, long long b, long long mo) {
  if (!a) return 0;
  long long tmp = 1;
  for (; b; b >>= 1) {
    if (b & 1) tmp = (long long)tmp * a % mo;
    a = (long long)a * a % mo;
  }
  return tmp;
}
char ty, s[1000011];
int L[1000011], R[1000011], st[1000011], tp, n;
bool f[1000011][2][2];
int main() {
  scanf("%*d %s", s + 1);
  n = strlen(s + 1);
  for (int i = (1); i <= (n); i++) {
    if (s[i] == '(')
      st[++tp] = i;
    else if (s[i] == ')')
      R[st[tp]] = i, L[i] = st[tp--];
    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;
  }
  int l, r;
  for (int i = (1); i <= (n); i++)
    if (s[i] == ')') {
      if (s[i - 1] != ')')
        ty = s[i - 2], l = i - 3, r = i - 1;
      else
        ty = s[L[i - 1] - 1], l = L[i - 1] - 2, r = i - 1;
      for (int a = 0; a < (int)(2); a++)
        for (int b = 0; b < (int)(2); b++)
          if (f[l][a][b])
            for (int c = 0; c < (int)(2); c++)
              for (int d = 0; d < (int)(2); d++)
                if (f[r][c][d]) {
                  if (ty == '&') f[i][a & c][b & d] = 1;
                  if (ty == '|') f[i][a | c][b | d] = 1;
                  if (ty == '^') f[i][a ^ c][b ^ d] = 1;
                }
    }
  puts((f[n][0][1] || f[n][1][0]) ? "YES" : "NO");
  return 0;
}
