#include <bits/stdc++.h>
int solve() {
  char c = getchar();
  if (c == '0') return 1;
  if (c == '1') return 32768;
  if (c == '?') return 5120;
  int x = solve();
  c = getchar();
  int y = solve(), z = 0;
  for (int i = 0; i < 16; i++)
    for (int j = 0; j < 16; j++)
      if (((x >> i) & 1) && ((y >> j) & 1)) {
        if (c == '^') z |= 1 << (i ^ j);
        if (c == '|') z |= 1 << (i | j);
        if (c == '&') z |= 1 << (i & j);
      }
  getchar();
  return z;
}
int main() {
  scanf("%*d ");
  puts(solve() & ~0x8241 ? "YES" : "NO");
}
