#include <bits/stdc++.h>
char get(char x, char y, char p) {
  return p == '&' ? x & y : p == '|' ? x | y : x ^ y;
}
char work() {
  char ch = getchar(), L, R, opr, res = 0;
  if (ch == '(') {
    L = work(), opr = getchar(), R = work(), getchar();
    for (char i = 0; i < 4; i++)
      if (L & 1 << i)
        for (char j = 0; j < 4; j++)
          if (R & 1 << j) res |= 1 << get(i, j, opr);
    return res;
  } else
    return ch == '0' ? 1 : ch == '1' ? 8 : 6;
}
int main() { scanf("%*d "), puts(work() & 6 ? "YES" : "NO"); }
