#include <bits/stdc++.h>
using namespace std;
namespace IO {
template <typename T>
void __RI(T &x) {
  int ch = getchar(), neg = 1;
  x = 0;
  for (; !(isdigit(ch) || ch == '-' || ch == EOF); ch = getchar())
    ;
  if (ch == EOF) return;
  if (ch == '-') neg = -1, ch = getchar();
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
  x *= neg;
}
void R(int &x) { __RI(x); }
void R(int64_t &x) { __RI(x); }
template <typename T1, typename T2>
void R(std::pair<T1, T2> &x) {
  R(x.first);
  R(x.second);
}
template <typename T>
void R(std::vector<T> &x) {
  for (auto &i : x) {
    R(i);
  }
}
template <typename T>
void R(T &x) {
  std::cin >> x;
}
template <typename T, typename... Args>
void R(T &x, Args &...args) {
  R(x), R(args...);
}
char space = ' ';
template <typename T>
void __WI(T x) {
  if (x == 0) putchar('0');
  if (x < 0) putchar('-'), x = -x;
  char ch[64];
  int pos = 0;
  while (x) ch[pos++] = x % 10 + 48, x /= 10;
  while (pos) putchar(ch[--pos]);
}
void W() {}
void W(const int &x) { __WI(x); }
void W(const int64_t &x) { __WI(x); }
void W(const double &x) { printf("%lf", static_cast<double>(x)); }
void W(const char &x) { putchar(x); }
void W(const std::string &x) { printf("%s", x.c_str()); }
template <typename T1, typename T2>
void W(const std::pair<T1, T2> &x) {
  W(x.first);
  W(space);
  W(x.second);
}
template <typename T>
void W(const std::vector<T> &x) {
  for (auto it = x.cbegin(); it != x.cend(); it++) {
    W(*it);
    W(space);
  }
  W('\n');
}
template <typename T>
void W(const T &x) {
  std::cout << x;
}
template <typename T, typename... Args>
void W(const T &x, const Args &...args) {
  W(x), W(space), W(args...);
}
template <typename... Args>
void WL(const Args &...args) {
  W(args...), W('\n');
}
};  // namespace IO
int n;
char s[1000010];
int pos;
void dfs(int res[]) {
  for (int i = 0; i <= 4; i++) res[i] = 0;
  if (s[pos] == '0') {
    res[0] = 1, pos++;
    return;
  }
  if (s[pos] == '1') {
    res[3] = 1, pos++;
    return;
  }
  if (s[pos] == '?') {
    res[1] = res[2] = 1, pos++;
    return;
  }
  pos++;
  int p[5];
  dfs(p);
  char op = s[pos];
  pos++;
  int q[5];
  dfs(q);
  pos++;
  for (int i = 0; i < 4; i++)
    if (p[i])
      for (int j = 0; j < 4; j++)
        if (q[j])
          if (op == '&')
            res[i & j] = 1;
          else if (op == '^')
            res[i ^ j] = 1;
          else if (op == '|')
            res[i | j] = 1;
}
int main() {
  IO::R(n, s);
  int dp[5];
  int pos = 0;
  dfs(dp);
  if (dp[1] || dp[2])
    IO::WL("YES");
  else
    IO::WL("NO");
  return 0;
}
