{$APPTYPE CONSOLE}

const
  NMAX = 100;

var
  a: array[-NMAX..NMAX, -NMAX..NMAX] of integer;
  s: string;

procedure makeA;
var
  i,j: Integer;
  p: string;

  function getvar(var i: integer): integer;
  var
    v: integer;
    ne: boolean;
  begin
    v := 0;
    if p[i]='~' then begin ne:=true; i:=i+2; end else begin ne:=false; i:=i+1; end;
    while p[i] in ['0'..'9'] do
    begin
      v := v * 10 + (ord(p[i]) - ord('0'));
      inc(i);
    end;
    if ne then v := -v;
    getvar := v;
  end;

  procedure pair;
  var
    v1,v2: integer;
    i: integer;
  begin
    i := 1;
    v1 := getvar(i);
    while (p[i]<>'x') and (p[i]<>'~') do inc(i);
    v2 := getvar(i);
    if (v1=-v2) then exit;
    a[-v1][v2] := 1; a[-v2][v1] := 1;
  end;

begin
  fillchar(a,sizeof(a),0);
  repeat
    i := Pos('(', s); if i=0 then break;
    j := Pos(')', s);
    p := Copy(s, i+1, j-i-1);
    pair;
    delete(s,i, j-i+1);
  until false;
end;

procedure Floyd;
var
  i,j,k: Integer;
begin
  for k:=-NMAX to NMAX do
    for i:=-NMAX to NMAX do
      for j:=-NMAX to NMAX do
        if (a[i][k]=1) and (a[k][j]=1) then a[i][j]:=1;
end;

procedure answer;
var
  i: integer;
begin
  for i:=1 to NMAX do
    if (a[i][-i]=1) and (a[-i][i]=1) then begin writeln('NO'); exit; end;
  writeln('YES');
end;

begin

//  assign(input,'input.txt'); reset(input);
//  assign(output,'output.txt'); rewrite(output);

  readln(s);
  makeA;
  Floyd;
  answer;

end.

