#include <bits/stdc++.h>
int n;
int dp() {
  char c;
  int x, y, z = 0;
  scanf("%c", &c);
  if (c == '0') return 1;
  if (c == '1') return 8;
  if (c == '?') return 6;
  x = dp();
  scanf("%c", &c);
  y = dp();
  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));
          if (c == '|') z |= (1 << (i | j));
          if (c == '^') z |= (1 << (i ^ j));
        }
  scanf("%c", &c);
  return z;
}
int main() {
  scanf("%d ", &n);
  if (dp() & 6)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
