#include <bits/stdc++.h>
using namespace std;
int n;
int solve() {
  char order;
  scanf("%c", &order);
  if (order == '0') return 1;
  if (order == '1') return 8;
  if (order == '?') return 6;
  int x, y, i, j, res = 0;
  x = solve(), scanf("%c", &order), y = solve();
  for (i = 0; i < 4; ++i)
    for (j = 0; j < 4; ++j)
      if (((x >> i) & 1) && ((y >> j) & 1))
        res |= 1 << (order == '^' ? i ^ j : (order == '&' ? i & j : i | j));
  scanf("%c", &order);
  return res;
}
int main() {
  scanf("%d\n", &n);
  printf(solve() & 6 ? "YES" : "NO");
  return 0;
}
