#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
string s;
int len = 0, lenq = 0, match[1000010], matcho[1000010], num[1000010],
    seq[1000010];
stack<int> st;
void INIT(int lb, int ub) {
  if (lb == ub) {
    if (s[lb] == '?') num[lb] = lenq++;
    return;
  }
  int now = len;
  INIT(lb + 1, matcho[lb] - 1);
  INIT(matcho[lb] + 1, ub - 1);
}
int getval(int lb, int ub) {
  if (lb == ub) {
    if (s[lb] == '?') return seq[num[lb]];
    return s[lb] - '0';
  }
  int a = getval(lb + 1, matcho[lb] - 1), b = getval(matcho[lb] + 1, ub - 1);
  if (s[matcho[lb]] == '|') return a | b;
  if (s[matcho[lb]] == '&') return a & b;
  return a ^ b;
}
int main() {
  srand((int)time(0));
  cin >> s >> s;
  int n = s.size();
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(') st.push(i);
    if (s[i] == ')') {
      match[st.top()] = i;
      st.pop();
    }
    if (s[i] == '|' || s[i] == '&' || s[i] == '^') matcho[st.top()] = i;
  }
  INIT(0, s.size() - 1);
  int p = getval(0, n - 1);
  for (int i = 0; i < lenq; i++) seq[i] = 1;
  if (getval(0, n - 1) != p) {
    puts("YES");
    return 0;
  }
  for (int rn = 0; rn < 60; rn++) {
    for (int i = 0; i < lenq; i++) seq[i] = rand() % 2;
    p = getval(0, n - 1);
    for (int i = 0; i < lenq; i++) seq[i] ^= 1;
    if (getval(0, n - 1) != p) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}
