#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, const U &b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, const U &b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T1, class T2>
inline void gn(T1 &x1, T2 &x2) {
  gn(x1), gn(x2);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
char s[1000100];
int p[1000100];
int calc(int a, int b, char c) {
  if (c == '|') return a | b;
  if (c == '&') return a & b;
  return a ^ b;
}
int solve(int L, int R) {
  if (L == R) {
    if (s[L] == '0') return 1;
    if (s[L] == '1') return 4;
    return 2;
  }
  int ls = solve(L + 1, p[L] - 1);
  int rs = solve(p[L] + 1, R - 1);
  int ans = 0;
  for (int a = 0; a < 2; a++)
    for (int b = 0; b < 2; b++)
      if ((ls >> a + b) & 1) {
        for (int first = 0; first < 2; first++)
          for (int second = 0; second < 2; second++)
            if ((rs >> first + second) & 1) {
              ans |= 1 << calc(a, first, s[p[L]]) + calc(b, second, s[p[L]]);
            }
      }
  return ans;
}
int main() {
  int n;
  cin >> n;
  scanf("%s", s);
  stack<int> st;
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    if (s[i] == '(')
      st.push(i);
    else if (s[i] == ')')
      st.pop();
    else if (s[i] == '|' || s[i] == '&' || s[i] == '^')
      p[st.top()] = i;
  }
  int ans = solve(0, n - 1);
  if (ans & 2)
    puts("YES");
  else
    puts("NO");
  return 0;
}
