#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
char s[1000005];
int i;
int dd(int a, int b, char x) {
  if (x == '&') return a & b;
  if (x == '|') return a | b;
  return a ^ b;
}
int dfs() {
  if (s[i] == '(') {
    i++;
    int x = dfs();
    char ope = s[i++];
    int y = dfs();
    i++;
    int z = 0;
    for (int(p) = 0; (p) < (int)(4); (p)++)
      if (x >> p & 1) {
        for (int(q) = 0; (q) < (int)(4); (q)++)
          if (y >> q & 1) {
            z |= 1 << dd(p, q, ope);
          }
      }
    return z;
  } else {
    i++;
    if (s[i - 1] == '0')
      return 1;
    else if (s[i - 1] == '1')
      return 8;
    else
      return 6;
  }
}
int main() {
  scanf("%d%s", &n, s);
  puts(dfs() & 6 ? "YES" : "NO");
  return 0;
}
