#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using std::bitset;
using namespace std;
char st[1001000];
int n, ans;
int dfs(int a, int &b) {
  int i, j, tem, x, c, y, ans;
  char ch;
  b = a + 1;
  if (st[a] == '0')
    return (1ll << (0));
  else if (st[a] == '1')
    return (1ll << (15));
  else if (st[a] == '?')
    return (1ll << (3)) | (1ll << (12));
  x = dfs(a + 1, c);
  ch = st[c];
  y = dfs(c + 1, b);
  b++;
  ans = 0;
  for (i = 0; i < 16; i++)
    if (x & (1ll << (i)))
      for (j = 0; j < 16; j++)
        if (y & (1ll << (j))) {
          if (ch == '^') tem = i ^ j;
          if (ch == '&') tem = i & j;
          if (ch == '|') tem = i | j;
          ans |= (1ll << (tem));
        }
  return ans;
}
int main() {
  int i, j, tem;
  while (scanf("%d%s", &n, st) != EOF) {
    ans = dfs(0, tem);
    for (i = 0; i < 16; i++)
      if (ans & (1ll << (i)))
        if (i != 0 && i != 15 && i != 6 && i != 9) break;
    if (i < 16)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
