#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 1000000;
char buf[kMaxN + 1];
int n, cnt;
bool dp[kMaxN * 2 - 1][2][2];
int Calc(int l, int r, int v) {
  if (l == r) {
    if (buf[l] == '?') return v;
    return (buf[l] - '0');
  }
  ++l, --r;
  int cnt = 0, pos = -1;
  for (int i = l; i <= r; ++i)
    if (buf[i] == '(')
      ++cnt;
    else if (buf[i] == ')')
      --cnt;
    else if (buf[i] == '&' || buf[i] == '|' || buf[i] == '^') {
      if (cnt == 0) {
        pos = i;
        break;
      }
    }
  int lv = Calc(l, pos - 1, v);
  int rv = Calc(pos + 1, r, v);
  if (buf[pos] == '&')
    return (lv & rv);
  else if (buf[pos] == '|')
    return (lv | rv);
  else
    return (lv ^ rv);
}
int Dfs(int l, int r) {
  int res = cnt++;
  if (l == r) {
    if (buf[l] == '?') {
      dp[res][0][1] = dp[res][1][0] = true;
    } else {
      dp[res][buf[l] - '0'][buf[l] - '0'] = true;
    }
  } else {
    ++l, --r;
    int cnt = 0, pos = -1;
    for (int i = l; i <= r; ++i)
      if (buf[i] == '(')
        ++cnt;
      else if (buf[i] == ')')
        --cnt;
      else if (buf[i] == '&' || buf[i] == '|' || buf[i] == '^') {
        if (cnt == 0) {
          pos = i;
          break;
        }
      }
    int ls = Dfs(l, pos - 1), rs = Dfs(pos + 1, r);
    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 (buf[pos] == '&')
                  e = a & c, f = b & d;
                else if (buf[pos] == '|')
                  e = a | c, f = b | d;
                else
                  e = a ^ c, f = b ^ d;
                dp[res][e][f] = true;
              }
  }
  return res;
}
int main() {
  scanf("%d%s", &n, buf);
  n = strlen(buf);
  int v0 = Calc(0, n - 1, 0);
  int v1 = Calc(0, n - 1, 1);
  if (v0 != v1) {
    printf("YES\n");
    return 0;
  }
  Dfs(0, n - 1);
  if (dp[0][0][1] || dp[0][1][0])
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
