#include <bits/stdc++.h>
using namespace std;
vector<char> op;
vector<array<array<bool, 2>, 2> > nums;
array<array<bool, 2>, 2> build(int x, int y) {
  array<array<bool, 2>, 2> res;
  res[0][0] = res[0][1] = res[1][0] = res[1][1] = false;
  res[x][y] = true;
  return res;
}
void doOp(char op) {
  array<array<bool, 2>, 2> b = nums.back();
  nums.pop_back();
  array<array<bool, 2>, 2> a = nums.back();
  nums.pop_back();
  array<array<bool, 2>, 2> cur;
  cur[0][0] = cur[0][1] = cur[1][0] = cur[1][1] = false;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      if (a[i][j])
        for (int k = 0; k < 2; k++)
          for (int l = 0; l < 2; l++)
            if (b[k][l])
              if (op == '&')
                cur[i & k][j & l] = true;
              else if (op == '|')
                cur[i | k][j | l] = true;
              else if (op == '^')
                cur[i ^ k][j ^ l] = true;
  nums.push_back(cur);
}
int main() {
  scanf("%*[^\n]");
  int ch = getchar();
  while (ch != EOF) {
    if (ch == '(')
      op.push_back('(');
    else if (ch == ')') {
      while (op.back() != '(') {
        doOp(op.back());
        op.pop_back();
      }
      op.pop_back();
    } else if (ch == '0') {
      nums.push_back(build(0, 0));
    } else if (ch == '1') {
      nums.push_back(build(1, 1));
    } else if (ch == '?') {
      array<array<bool, 2>, 2> cur;
      cur[0][0] = cur[1][1] = false;
      cur[1][0] = cur[0][1] = true;
      nums.push_back(cur);
    } else if (ch == '&' || ch == '|' || ch == '^')
      op.push_back(ch);
    else if (!op.empty() || !nums.empty())
      break;
    ch = getchar();
  }
  puts(nums.back()[0][1] ? "YES" : "NO");
  return 0;
}
