#include <bits/stdc++.h>
using namespace std;
int len, pt;
char s[1000050];
inline int OR(int a, int b) {
  return (1 << max(a, b)) | (a == 1 && b == 1 ? 4 : 0);
}
inline int AND(int a, int b) {
  return (1 << min(a, b)) | (a == 1 && b == 1 ? 1 : 0);
}
inline int XOR(int a, int b) {
  if (a != 1 && b != 1) {
    if (a == b)
      return 1;
    else
      return 4;
  } else if (a == 1 && b == 1) {
    return 1 | 4;
  } else {
    return 2;
  }
}
inline int calc(int a, int b, int op) {
  int r = 0;
  for (int i = 0; i < 3; i++) {
    if (!(a & (1 << i))) continue;
    for (int j = 0; j < 3; j++) {
      if (!(b & (1 << j))) continue;
      if (op == 0) r |= OR(i, j);
      if (op == 1) r |= AND(i, j);
      if (op == 2) r |= XOR(i, j);
    }
  }
  return r;
}
int go() {
  if (s[pt] == '(') {
    ++pt;
    int v1 = go();
    char op = s[pt++];
    int v2 = go();
    ++pt;
    int opid;
    if (op == '|') opid = 0;
    if (op == '&') opid = 1;
    if (op == '^') opid = 2;
    return calc(v1, v2, opid);
  } else {
    char c = s[pt++];
    if (c == '0') return 1;
    if (c == '1') return 4;
    return 2;
  }
}
bool solve() {
  pt = 0;
  int res = go();
  return (res & 2) ? 1 : 0;
}
int main(void) {
  scanf("%*d");
  scanf("%s", s);
  len = strlen(s);
  puts(solve() ? "YES" : "NO");
  return 0;
}
