#include <bits/stdc++.h>
using namespace std;
bool ans[16][500010];
char s[1000010];
int p, cnt;
bool decis;
int calc() {
  int act = cnt++;
  if (s[p] != '(') {
    if (s[p] == '0')
      ans[0][act] = 1;
    else if (s[p] == '1')
      ans[15][act] = 1;
    else {
      if (decis) ans[0][act] = ans[15][act] = 1;
      ans[10][act] = 1;
      ans[12][act] = 1;
    }
    p++;
    return act;
  }
  p++;
  int st = calc();
  char op = s[p++];
  int dr = calc();
  p++;
  if (op == '&') {
    for (int i(0); i < 16; i++) {
      if (!ans[i][st]) continue;
      for (int j(0); j < 16; j++) ans[i & j][act] |= ans[j][dr];
    }
  } else if (op == '|') {
    for (int i(0); i < 16; i++) {
      if (!ans[i][st]) continue;
      for (int j(0); j < 16; j++) ans[i | j][act] |= ans[j][dr];
    }
  }
  if (op == '^') {
    for (int i(0); i < 16; i++) {
      if (!ans[i][st]) continue;
      for (int j(0); j < 16; j++) ans[i ^ j][act] |= ans[j][dr];
    }
  }
  return act;
}
int main() {
  int n;
  cin >> n;
  cin >> s;
  int nod = calc();
  bool ok(0), canizol(0), canfind(0);
  for (int i(0); i < 16; i++) {
    if (!ans[i][nod]) continue;
    if ((i & 1) != (i & 8) / 8) ok = 1;
    if ((i & 2) / 2 != (i & 1) || (i & 4) / 4 != (i & 1)) canizol = 1;
    if ((i & 2) / 2 != (i & 4) / 4) canfind = 1;
  }
  if (ok) {
    cout << "YES\n";
    return 0;
  }
  if (!canizol || !canfind) {
    cout << "NO\n";
    return 0;
  }
  decis = 1;
  memset(ans, 0, sizeof ans);
  cnt = 0;
  nod = calc();
  for (int i(0); i < 16; i++) {
    if (!ans[i][nod]) continue;
    if ((i & 1) != (i & 8) / 8) {
      cout << "YES\n";
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}
