#include <bits/stdc++.h>
const int MOD = 1E9 + 7;
const int N = 5000 + 5;
const int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
const int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
using namespace std;
char get(char x, char y, char ch) {
  if (ch == '&')
    return x & y;
  else if (ch == '|')
    return x | y;
  else if (ch == '^')
    return x ^ y;
}
char work() {
  char ch = getchar();
  char res = 0;
  if (ch == '(') {
    char L = work();
    char opr = getchar();
    char R = work();
    getchar();
    for (char i = 0; i < 4; i++)
      if (L & 1 << i)
        for (char j = 0; j < 4; j++)
          if (R & 1 << j) res |= 1 << get(i, j, opr);
    return res;
  } else {
    if (ch == '0')
      return 1;
    else if (ch == '1')
      return 8;
    else
      return 6;
  }
}
int main() {
  int n;
  scanf("%d ", &n);
  if (work() & 6)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
