#include <bits/stdc++.h>
char str[2000000];
int l;
int calc(int a, int b, char c) {
  if (c == '|') return (a | b);
  if (c == '&') return (a & b);
  if (c == '^') return (a ^ b);
}
int dfs() {
  if (str[l] == '0') {
    l++;
    return 1 << 0;
  }
  if (str[l] == '1') {
    l++;
    return 1 << 1;
  }
  if (str[l] == '?') {
    l++;
    return 1 << 2;
  }
  ++l;
  int a = dfs();
  char op = str[l];
  ++l;
  int b = dfs();
  ++l;
  int re = 0;
  for (int i = 0; i <= 2; i++) {
    if ((a & (1 << i)) == 0) continue;
    for (int j = 0; j <= 2; j++) {
      if ((b & (1 << j)) == 0) continue;
      if (i < 2 && j < 2) re |= 1 << (calc(i, j, op));
      if (i == 2 && j < 2) {
        if (calc(1, j, op) != calc(0, j, op))
          re |= 1 << 2;
        else
          re |= 1 << (calc(0, j, op));
      }
      if (i < 2 && j == 2) {
        if (calc(i, 1, op) != calc(i, 0, op))
          re |= 1 << 2;
        else
          re |= 1 << (calc(i, 0, op));
      }
      if (i == 2 && j == 2) {
        if (calc(0, 0, op) == calc(1, 1, op))
          re |= 1 << (calc(0, 0, op));
        else
          re |= 1 << 2;
        re |= 1 << (calc(0, 1, op));
      }
    }
  }
  return re;
}
int main() {
  int n;
  char c;
  scanf("%d", &n);
  scanf("%s", str);
  l = 0;
  if (dfs() & (1 << 2))
    printf("YES\n");
  else
    printf("NO\n");
}
