#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m;
char p[1000010];
int dfs(int l, int r) {
  if (l == r) return p[l] == '0' ? 1 : p[l] == '1' ? 8 : 6;
  int i, j, s = 0;
  l++, r--;
  for (i = l; i <= r; i++) {
    if (p[i] == '(') s++;
    if (p[i] == ')') s--;
    if (!s) break;
  }
  char P = p[i + 1];
  int A = dfs(l, i), B = dfs(i + 2, r), C = 0;
  for (i = 0; i <= 3; i++)
    for (j = 0; j <= 3; j++)
      if (A >> i & 1 && B >> j & 1)
        C |= 1 << (P == '&' ? i & j : P == '^' ? i ^ j : i | j);
  return C;
}
int main() {
  scanf("%d", &n);
  scanf("%s", p + 1);
  n = strlen(p + 1);
  if (dfs(1, n) & 6)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
