#include <bits/stdc++.h>
using namespace std;
int work() {
  char c = getchar();
  int x, y, z = 0;
  if (c == '0') return 1;
  if (c == '1') return 8;
  if (c == '?') return 6;
  x = work();
  c = getchar();
  y = work();
  for (int i = 0; i < 4; i++)
    if (x & (1 << i))
      for (int j = 0; j < 4; j++)
        if (y & (1 << j))
          if (c == '&')
            z |= 1 << (i & j);
          else if (c == '|')
            z |= 1 << (i | j);
          else if (c == '^')
            z |= 1 << (i ^ j);
  getchar();
  return z;
}
int main() {
  int n;
  scanf("%d\n", &n);
  if (work() & 6)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
