#include <bits/stdc++.h>
using namespace std;
int work() {
  char c = getchar();
  if (c == '0')
    return 1;
  else if (c == '1')
    return 8;
  else if (c == '?')
    return 6;
  int x = work(), z = 0, y;
  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() {
  scanf("%*d");
  getchar();
  if (work() & 6)
    puts("YES");
  else
    puts("NO");
  return 0;
}
