//
// Written by Fyodor Menshikov 21.02.2006
// 5:51-6:25
//
var
   nPairs:integer;
   pairs:array[1..1000]of record
      ind1,ind2:integer;
      neg1,neg2:boolean;
   end;
var
   c:char;

   procedure nextchar;
   begin
      if eoln then
         c:=#13
      else
         read(c);
   end;

   procedure skip(s:string);
   var
      i:integer;
   begin
      for i:=1 to length(s) do begin
         assert(c=s[i]);
         nextchar;
      end;
   end;

   procedure number(var n:integer);
   begin
      assert(c in ['1'..'9']);
      n:=0;
      while c in ['0'..'9'] do begin
         n:=n*10+ord(c)-ord('0');
         nextchar;
         assert(n<=100);
      end;
   end;

   procedure variable(var neg:boolean;var ind:integer);
   begin
      neg:=false;
      if c='~' then begin
         neg:=true;
         nextchar;
      end;
      skip('x');
      number(ind);
   end;

   procedure disjunction;
   begin
      inc(nPairs);
      assert(nPairs<=high(pairs));
      skip('(');
      variable(pairs[nPairs].neg1,pairs[nPairs].ind1);
      skip(' OR ');
      variable(pairs[nPairs].neg2,pairs[nPairs].ind2);
      skip(')');
   end;

   procedure conjunction;
   begin
      disjunction;
      while c=' ' do begin
         skip(' AND ');
         disjunction;
      end;
   end;

   procedure getVariable(var ind:integer);
   begin
      assert(nPairs>0);
      ind:=pairs[1].ind1;
   end;

var
   defined:array[1..100]of boolean;
   value:array[1..100]of boolean;

   function possibleValue(ind:integer;val:boolean):boolean;
   var
      i,n:integer;
      changed:boolean;
   begin
      for i:=1 to 100 do begin
         defined[i]:=false;
      end;
      defined[ind]:=true;
      value[ind]:=val;
      repeat
         changed:=false;
         for i:=1 to nPairs do begin
            if defined[pairs[i].ind1] and defined[pairs[i].ind2] then begin
               if not (
                  (value[pairs[i].ind1] xor pairs[i].neg1) or 
                  (value[pairs[i].ind2] xor pairs[i].neg2))
               then begin
                  possibleValue:=false;
                  exit;
               end;
            end
            else if defined[pairs[i].ind1] then begin
               if (value[pairs[i].ind1] xor pairs[i].neg1)=false then begin
                  defined[pairs[i].ind2]:=true;
                  value[pairs[i].ind2]:=not pairs[i].neg2;
                  changed:=true;
               end;
            end
            else if defined[pairs[i].ind2] then begin
               if (value[pairs[i].ind2] xor pairs[i].neg2)=false then begin
                  defined[pairs[i].ind1]:=true;
                  value[pairs[i].ind1]:=not pairs[i].neg1;
                  changed:=true;
               end;
            end;
            {else nothing}
         end;
      until not changed;
      n:=0;
      for i:=1 to nPairs do begin
         if not defined[pairs[i].ind1] and not defined[pairs[i].ind2] then begin
            inc(n);
            pairs[n]:=pairs[i];
         end;
      end;
      nPairs:=n;
      possibleValue:=true;
   end;

var
   ind:integer;
begin
//   assign(input,'input.txt');
   reset(input);
//   assign(output,'output.txt');
   rewrite(output);
   nPairs:=0;
   nextchar;
   conjunction;
   assert(c=#13);
   while nPairs>0 do begin
      getVariable(ind);
      if possibleValue(ind,false) then begin
         continue;
      end;
      if possibleValue(ind,true) then begin
         continue;
      end;
      writeln('NO');
      halt;
   end;
   writeln('YES');
end.