#include <bits/stdc++.h>
using namespace std;
string s;
int calcula(int &is) {
  if (s[is] == '0') {
    is++;
    return 1;
  } else if (s[is] == '1') {
    is++;
    return 1 << 15;
  } else if (s[is] == '?') {
    is++;
    return (1 << (4 + 8)) | (1 << (2 + 8));
  }
  is++;
  int f1 = calcula(is);
  int op;
  if (s[is] == '&')
    op = 1;
  else if (s[is] == '|')
    op = 2;
  else
    op = 3;
  is++;
  int f2 = calcula(is);
  is++;
  int f = 0;
  for (int i1 = 0; i1 < 16; i1++)
    if (f1 & (1 << i1))
      for (int i2 = 0; i2 < 16; i2++)
        if (f2 & (1 << i2))
          if (op == 1)
            f |= 1 << (i1 & i2);
          else if (op == 2)
            f |= 1 << (i1 | i2);
          else
            f |= 1 << (i1 ^ i2);
  return f;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n >> s;
  int is = 0;
  int f = calcula(is);
  for (int i = 0; i < 16; i++) {
    if ((f & (1 << i)) and
        (((i & 2) == 0 and (i & 4)) or ((i & 2) and (i & 4) == 0))) {
      cout << "YES" << endl;
      exit(0);
    }
  }
  cout << "NO" << endl;
}
