#include <bits/stdc++.h>
using namespace std;
char F[1000007];
int C[1000007];
int solve(int x) {
  if (F[x] == '0') return 1 << 0;
  if (F[x] == '1') return 1 << 15;
  if (F[x] == '?') return (1 << 10) | (1 << 12);
  assert(F[x] == '(');
  int op = (F[x + 1] == '(') ? C[x + 1] + 1 : x + 2;
  int left = solve(x + 1);
  int right = solve(op + 1);
  int res = 0;
  if (F[op] == '|') {
    for (int i = 0; i < (int)(16); ++i)
      for (int j = 0; j < (int)(16); ++j)
        if ((left & (1 << i)) && (right & (1 << j))) res |= 1 << (i | j);
  } else if (F[op] == '&') {
    for (int i = 0; i < (int)(16); ++i)
      for (int j = 0; j < (int)(16); ++j)
        if ((left & (1 << i)) && (right & (1 << j))) res |= 1 << (i & j);
  } else {
    assert(F[op] == '^');
    for (int i = 0; i < (int)(16); ++i)
      for (int j = 0; j < (int)(16); ++j)
        if ((left & (1 << i)) && (right & (1 << j))) res |= 1 << (i ^ j);
  }
  return res;
}
int main() {
  int n;
  scanf("%d%s", &n, F);
  stack<int> S;
  for (int i = 0; F[i]; ++i)
    if (F[i] == '(') {
      S.push(i);
    } else if (F[i] == ')') {
      C[S.top()] = i;
      C[i] = S.top();
      S.pop();
    }
  int res = solve(0);
  bool R[16] = {false, true,  true, true, true, true, false, true,
                true,  false, true, true, true, true, true,  false};
  for (int i = 0; i < (int)(16); ++i)
    if (R[i] && (res & (1 << i))) {
      printf("YES\n");
      return 0;
    }
  printf("NO\n");
}
