#include <bits/stdc++.h>
using namespace std;
int cal(char ch, int x, int y) {
  if (ch == '|')
    return x | y;
  else if (ch == '&')
    return x & y;
  return x ^ y;
}
int work() {
  char ch;
  scanf("%c", &ch);
  if (ch == '0')
    return 1 << 0;
  else if (ch == '1')
    return 1 << 3;
  else if (ch == '?')
    return (1 << 1) | (1 << 2);
  int a = work();
  scanf("%c", &ch);
  int b = work();
  int ans = 0;
  for (int i = 0; i < 4; i++)
    if (a & (1 << i))
      for (int j = 0; j < 4; j++)
        if (b & (1 << j)) ans |= (1 << cal(ch, i, j));
  getchar();
  return ans;
}
int main() {
  int n;
  scanf("%d\n", &n);
  printf("%s\n", (work() & 6) ? "YES" : "NO");
  return 0;
}
