#include <bits/stdc++.h>
const int t = 1000005;
int sta[t], sig[t];
int cacu(bool a, int b, bool c) { return !b ? a | c : b == 1 ? a & c : a ^ c; }
void merge(int &a, int b, int c) {
  int d = 0;
  for (int i = 0; i < 4; i++)
    if (a & (1 << i))
      for (int j = 0; j < 4; j++)
        if (c & (1 << j))
          d |= 1 << (cacu(i > 1, b, j > 1) * 2 + cacu(i & 1, b, j & 1));
  a = d;
}
int main() {
  int i, tt;
  char a;
  scanf("%d", &i);
  a = getchar(), a = getchar();
  sta[0] = 1, sig[tt = 0] = 0;
  do {
    if (a == '(') {
      ++tt;
      sta[tt] = 1, sig[tt] = 0;
    } else if (a == ')') {
      merge(sta[tt - 1], sig[tt - 1], sta[tt]);
      --tt;
    } else if (a == '|')
      sig[tt] = 0;
    else if (a == '&')
      sig[tt] = 1;
    else if (a == '^')
      sig[tt] = 2;
    else if (a == '0' || a == '1')
      merge(sta[tt], sig[tt], a == '0' ? 1 : 8);
    else if (a == '?')
      merge(sta[tt], sig[tt], 6);
    a = getchar();
  } while (a != '\n' && a && a != -1);
  puts((sta[0] & 2) || (sta[0] & 4) ? "YES" : "NO");
  return 0;
}
