#include <bits/stdc++.h>   using namespace std;   int n, l[1000005], dp[1000005][2][2];   char s[1000005];   void Calc(int k) {     if (s[k] ==  0 )       dp[k][0][0] = 1;     else if (s[k] ==  1 )       dp[k][1][1] = 1;     else {       dp[k][1][0] = 1;       dp[k][0][1] = 1;     }   }   void Change(int x, int L, int R, int O) {     int tmp[2][2] = {0};     for (int a = 0; a < 2; a++)       for (int b = 0; b < 2; b++)         if (dp[L][a][b])           for (int c = 0; c < 2; c++)             for (int d = 0; d < 2; d++)               if (dp[R][c][d])                 if (s[O] ==  & )                   tmp[a & c][b & d] = 1;                 else if (s[O] ==  | )                   tmp[a | c][b | d] = 1;                 else                   tmp[a ^ c][b ^ d] = 1;     for (int a = 0; a < 2; a++)       for (int b = 0; b < 2; b++) dp[x][a][b] = tmp[a][b];   }   int Dfs(int l) {     int r = l + 1, L = -1, O = -1;     while (s[r] !=  ) ) {       if ((s[r] ==  ?  || s[r] ==  0  || s[r] ==  1 ) && L == -1)         Calc(r), L = r, O = r + 1;       if (s[r] ==  ( ) r = Dfs(r);       r++;       if (r - l >= 3 && s[r] !=  ( ) {         if (s[r] ==  ?  || s[r] ==  1  || s[r] ==  0 ) {           Calc(r);           if (L != -1) Change(r, L, r, O);           L = r;           O = r + 1;           r++;         } else {           if (L != -1) Change(r - 1, L, r - 1, O);           L = r - 1;           O = r;         }         O = r;       }     }     for (int a = 0; a < 2; a++)       for (int b = 0; b < 2; b++) dp[r][a][b] = dp[r - 1][a][b];     return r;   }   int main() {     scanf( %d , &n);     scanf( %s , &s);     int n = strlen(s) - 1, flag = 0;     for (int i = 0; i <= n; i++)       if (s[i] ==  ? ) flag = 1;     if (n == 0) {       if (s[0] ==  0  || s[0] ==  1 )         puts( NO );       else         puts( YES );       return 0;     }     Dfs(0);     if (((dp[n][0][1] || dp[n][1][0]) && flag) || n == 0)       puts( YES );     else       puts( NO );     return 0;   }   