#include <bits/stdc++.h>
const int mn = 1010000;
int n, i, j, r;
char s[mn];
int calc(char p, int x, int y) {
  if (p == '&') return x & y;
  if (p == '|') return x | y;
  if (p == '^') return x ^ y;
}
int solve() {
  ++r;
  if (s[r] == '0') return 1;
  if (s[r] == '1') return 8;
  if (s[r] == '?') return 6;
  int x = solve();
  char p = s[++r];
  int y = solve();
  int i, j, res = 0;
  for (i = 0; i <= 3; ++i)
    for (j = 0; j <= 3; ++j)
      if ((x & (1 << i)) != 0 && (y & (1 << j)) != 0) res |= 1 << calc(p, i, j);
  ++r;
  return res;
}
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  if ((solve() & 6))
    puts("YES");
  else
    puts("NO");
  return 0;
}
