#include <bits/stdc++.h>
using namespace std;
const int maxn = 1100000;
int n;
char A[maxn];
namespace Ninit {
void init() { scanf("%*d%s", A), n = strlen(A); }
}  // namespace Ninit
namespace Nsolve {
int F[maxn], N;
char Fop[maxn];
bool C1(char x) { return x == '?' || x == '0' || x == '1'; }
bool C2(char x) { return x == '^' || x == '&' || x == '|'; }
int F1(int a, int b, char op) {
  return op == '^' ? a ^ b : op == '|' ? a | b : a & b;
}
int F2(int b, char op) {
  return op == '^'   ? (b & 1 ? 4 : 0) | (b & 2 ? 4 : 0) | (b & 4 ? 3 : 0)
         : op == '&' ? (b & 1 ? 1 : 0) | (b & 2 ? 4 : 0) | (b & 4 ? 5 : 0)
                     : (b & 1 ? 4 : 0) | (b & 2 ? 2 : 0) | (b & 4 ? 6 : 0);
}
int comb(int a, int b, char op) {
  int Fc = 0, i, j;
  for (i = 0; i < 2; ++i)
    for (j = 0; j < 2; ++j)
      if (a & (1 << i) && b & (1 << j)) Fc |= 1 << F1(i, j, op);
  if (a & 4) Fc |= F2(b, op);
  if (b & 4) Fc |= F2(a, op);
  return Fc;
}
void solve() {
  int i;
  char *p;
  for (N = 0, p = A; p < A + n; ++p)
    if (*p != '(') {
      if (C1(*p))
        F[++N] = (*p == '?' ? 4 : *p == '0' ? 1 : 2);
      else if (C2(*p))
        Fop[N] = *p;
      else
        F[N - 1] = comb(F[N - 1], F[N], Fop[N - 1]), --N;
    }
  printf(F[1] & 4 ? "YES\n" : "NO\n");
}
}  // namespace Nsolve
int main() {
  Ninit::init();
  Nsolve::solve();
  return 0;
}
