#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int AND[16][16], OR[16][16], XOR[16][16];
int n, mmp;
char s[N];
int match[N];
stack<int> br;
int parse(int lft, int rht) {
  if (lft == rht) {
    if (s[lft] == '0') return 1;
    if (s[lft] == '1') return 8;
    return 6;
  }
  int L = parse(lft + 1, match[lft + 1]);
  int R = parse(match[rht - 1], rht - 1);
  char op = s[match[lft + 1] + 1];
  if (op == '&') return AND[L][R];
  if (op == '|') return OR[L][R];
  return XOR[L][R];
}
int main() {
  for (int i = 0; i < 16; i++)
    for (int j = 0; j < 16; j++)
      for (int m1 = 0; m1 < 4; m1++)
        for (int m2 = 0; m2 < 4; m2++) {
          int a = m1 >> 1, b = m1 & 1;
          int c = m2 >> 1, d = m2 & 1;
          int e, f;
          if (~i & (1 << m1)) continue;
          if (~j & (1 << m2)) continue;
          e = a & c;
          f = b & d;
          AND[i][j] |= (1 << ((e << 1) ^ f));
          e = a | c;
          f = b | d;
          OR[i][j] |= (1 << ((e << 1) ^ f));
          e = a ^ c;
          f = b ^ d;
          XOR[i][j] |= (1 << ((e << 1) ^ f));
        }
  scanf("%d%s", &mmp, s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) match[i] = i;
  for (int i = 1; i <= n; i++) {
    if (s[i] == '(') br.push(i);
    if (s[i] == ')') {
      int j = br.top();
      br.pop();
      match[i] = j;
      match[j] = i;
    }
  }
  if (parse(1, n) & 6)
    puts("YES");
  else
    puts("NO");
  return 0;
}
