#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
inline int get_val(int x, char op, int y) {
  if (op == '&') return x & y;
  if (op == '|') return x | y;
  if (op == '^') return x ^ y;
  throw ~0;
}
char str[1000005];
int dfs(int &cur) {
  register char ch;
  ch = str[cur++];
  if (ch == '0') return 0;
  if (ch == '1') return 1;
  assert(ch == '(');
  int left = dfs(cur);
  ch = str[cur++];
  int right = dfs(cur);
  int res = get_val(left, ch, right);
  ch = str[cur++];
  assert(ch == ')');
  return res;
}
int pos[1000000], sz;
int gtp[1000000];
int main() {
  srand(time(NULL));
  scanf("%*d\n%s", str);
  int n = strlen(str);
  for (int i = 0; i < n; ++i)
    if (str[i] == '?') pos[++sz] = i;
  while (clock() * 1000.0 / CLOCKS_PER_SEC <= 900) {
    int now, res1, res2;
    for (int i = 1; i <= sz; ++i) gtp[i] = rand() & 1;
    for (int i = 1; i <= sz; ++i) str[pos[i]] = gtp[i] + '0';
    now = 0, res1 = dfs(now), assert(now == n);
    for (int i = 1; i <= sz; ++i) str[pos[i]] = (gtp[i] ^ 1) + '0';
    now = 0, res2 = dfs(now), assert(now == n);
    if (res1 != res2) return puts("YES") & 0;
  }
  puts("NO");
  return 0;
}
