#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 1000000;
char buf[kMaxN + 1];
int n;
const int kMaxM = kMaxN * 2 - 1;
int m, pre[kMaxM], son[kMaxM][2];
bool dp[kMaxM][2][2], val[kMaxM];
int q[kMaxM][2], qh, qt;
char p[kMaxM];
namespace st {
int dp[20][kMaxN];
int rec[kMaxN + 1], *sum = rec + 1;
int log2[kMaxN + 1];
void Init() {
  log2[1] = 0;
  for (int i = 2; i <= n; ++i) {
    log2[i] = log2[i - 1];
    if ((i & (i - 1)) == 0) ++log2[i];
  }
  int t = log2[n] + 1;
  for (int i = 0; i < n; ++i) {
    sum[i] = sum[i - 1];
    if (buf[i] == '(') ++sum[i];
    if (buf[i] == ')') --sum[i];
  }
  for (int i = 0; i < n; ++i) dp[0][i] = i;
  for (int j = 1; j < t; ++j)
    for (int i = 0; i < n; ++i) {
      dp[j][i] = dp[j - 1][i];
      if (i + (1 << (j - 1)) < n &&
          sum[dp[j - 1][i + (1 << (j - 1))]] <= sum[dp[j][i]])
        dp[j][i] = dp[j - 1][i + (1 << (j - 1))];
    }
}
int Query(int l, int r) {
  int s = log2[r - l + 1];
  if (sum[dp[s][l]] < sum[dp[s][r - (1 << s) + 1]])
    return dp[s][l];
  else
    return dp[s][r - (1 << s) + 1];
}
}  // namespace st
bool Calc(bool v) {
  for (int i = qt - 1; i >= 0; --i) {
    int l = q[i][0], r = q[i][1];
    if (l == r) {
      if (buf[l] == '?')
        val[i] = v;
      else
        val[i] = buf[l] - '0';
    } else {
      bool lv = val[son[i][0]], rv = val[son[i][1]];
      if (p[i] == '&')
        val[i] = lv & rv;
      else if (p[i] == '|')
        val[i] = lv | rv;
      else
        val[i] = lv ^ rv;
    }
  }
  return val[0];
}
void Bfs() {
  for (int i = qt - 1; i >= 0; --i) {
    int l = q[i][0], r = q[i][1];
    if (l == r) {
      if (buf[l] == '?')
        dp[i][0][1] = dp[i][1][0] = true;
      else
        dp[i][buf[l] - '0'][buf[l] - '0'] = true;
    } else {
      int ls = son[i][0], rs = son[i][1];
      for (int a = 0; a < 2; ++a)
        for (int b = 0; b < 2; ++b)
          if (dp[ls][a][b])
            for (int c = 0; c < 2; ++c)
              for (int d = 0; d < 2; ++d)
                if (dp[rs][c][d]) {
                  int e, f;
                  if (p[i] == '&')
                    e = a & c, f = b & d;
                  else if (p[i] == '|')
                    e = a | c, f = b | d;
                  else
                    e = a ^ c, f = b ^ d;
                  dp[i][e][f] = true;
                }
    }
  }
}
int main() {
  scanf("%d%s", &n, buf);
  n = strlen(buf);
  st::Init();
  memset(son, -1, sizeof(son));
  q[qt][0] = 0, q[qt++][1] = n - 1, pre[0] = -1;
  while (qh < qt) {
    int &l = q[qh][0], &r = q[qh][1];
    if (buf[l] == '(') ++l, --r;
    if (l < r) {
      int po = st::Query(l, r - 1);
      for (int i = po - 1; i <= po + 1; ++i)
        if (i >= 0 && i < n) {
          if (buf[i] != '&' && buf[i] != '|' && buf[i] != '^') continue;
          po = i;
          break;
        }
      son[qh][0] = qt, q[qt][0] = l, q[qt++][1] = po - 1;
      son[qh][1] = qt, q[qt][0] = po + 1, q[qt++][1] = r;
      p[qh] = buf[po];
    }
    ++qh;
  }
  bool v0 = Calc(0), v1 = Calc(1);
  if (v0 != v1) {
    printf("YES\n");
    return 0;
  }
  Bfs();
  if (dp[0][0][1] || dp[0][1][0])
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
