#include <bits/stdc++.h>
using namespace std;
int bit(int x, int y) { return (x >> y) & 1; }
void renew(char c, int &x, int y) {
  int v0, v1, v2;
  if (c == '|') {
    v0 = bit(x, 0) & bit(y, 0);
    v1 = bit(x, 1) | bit(y, 1) | bit(x, 2) & bit(y, 2);
    v2 = (bit(x, 2) | bit(x, 0)) & bit(y, 2) | bit(x, 2) & bit(y, 0);
  }
  if (c == '&') {
    v0 = bit(x, 0) | bit(y, 0) | bit(x, 2) & bit(y, 2);
    v1 = bit(x, 1) & bit(x, 1);
    v2 = (bit(x, 2) | bit(x, 1)) & bit(y, 2) | bit(x, 2) & bit(y, 1);
  }
  if (c == '^') {
    v0 = bit(x, 1) & bit(y, 1) | bit(x, 0) & bit(y, 0) | bit(x, 2) & bit(y, 2);
    v1 = bit(x, 0) & bit(y, 1) | bit(x, 1) & bit(y, 0) | bit(x, 2) & bit(y, 2);
    v2 = bit(x, 2) & (bit(y, 0) | bit(y, 1)) |
         (bit(x, 0) | bit(x, 1)) & bit(y, 2);
  }
  x = v0 + v1 * 2 + v2 * 4;
}
int work() {
  char c = getchar();
  if (c == '0') return 1;
  if (c == '1') return 2;
  if (c == '?') return 4;
  int p = work();
  for (;;) {
    c = getchar();
    if (c == ')') return p;
    renew(c, p, work());
  }
}
int main() {
  scanf("%*d ");
  puts(bit(work(), 2) ? "YES" : "NO");
}
