#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, cur = 1;
string s;
int pos[N], br[N];
bool dp[3][N];
char c[N];
int parse(int i, int j) {
  int id = cur++;
  if (s[i] == '0' or s[i] == '1' or s[i] == '?') {
    c[id] = s[i];
    if (c[id] == '0') {
      dp[0][id] = 1;
      dp[1][id] = 0;
      dp[2][id] = 0;
    } else if (c[id] == '1') {
      dp[0][id] = 0;
      dp[1][id] = 1;
      dp[2][id] = 0;
    } else {
      dp[0][id] = 0;
      dp[1][id] = 0;
      dp[2][id] = 1;
    }
  } else {
    i++;
    int ind;
    if (s[i] == '0' or s[i] == '1' or s[i] == '?')
      ind = i + 1;
    else
      ind = br[i] + 1;
    c[id] = s[ind];
    int l = parse(i, ind - 1);
    int r = parse(ind + 1, j - 1);
    if (c[id] == '&') {
      dp[0][id] = (dp[1][l] && dp[0][r]) or (dp[2][l] && dp[2][r]) or
                  (dp[2][l] && dp[0][r]);
      dp[0][id] = dp[0][id] or (dp[0][l] && dp[0][r]) or
                  (dp[0][l] && dp[1][r]) or (dp[0][l] && dp[2][r]);
      dp[1][id] = dp[1][l] && dp[1][r];
      dp[2][id] = (dp[2][l] && dp[1][r]) or (dp[1][l] && dp[2][r]) or
                  (dp[2][l] && dp[2][r]);
    } else if (c[id] == '|') {
      dp[0][id] = dp[0][l] && dp[0][r];
      dp[1][id] = (dp[2][l] && dp[2][r]) or (dp[2][l] && dp[1][r]) or
                  (dp[1][l] && dp[2][r]);
      dp[1][id] = dp[1][id] or (dp[1][l] && dp[0][r]) or
                  (dp[0][l] && dp[1][r]) or (dp[1][l] && dp[1][r]);
      dp[2][id] = (dp[2][l] && dp[0][r]) or (dp[0][l] && dp[2][r]) or
                  (dp[2][l] && dp[2][r]);
    } else if (c[id] == '^') {
      dp[0][id] = (dp[2][l] && dp[2][r]) or (dp[1][l] && dp[1][r]) or
                  (dp[0][l] && dp[0][r]);
      dp[1][id] = (dp[2][l] && dp[2][r]) or (dp[1][l] && dp[0][r]) or
                  (dp[0][l] && dp[1][r]);
      dp[2][id] = (dp[2][l] && dp[1][r]) or (dp[2][l] && dp[0][r]) or
                  (dp[0][l] && dp[2][r]) or (dp[1][l] && dp[2][r]);
    }
  }
  return id;
}
int main() {
  ios_base::sync_with_stdio(0);
  int col;
  cin >> col;
  cin >> s;
  n = s.size();
  stack<int> st;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      st.push(i);
    } else if (s[i] == ')') {
      br[i] = st.top();
      br[st.top()] = i;
      st.pop();
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] != ')' and s[i] != '(') continue;
    br[br[i]] = i;
  }
  parse(0, n - 1);
  if (dp[2][1])
    cout << "YES\n";
  else
    cout << "NO\n";
}
