{$APPTYPE CONSOLE}

var
  i, current, n, m : integer;
  a : array [1..10000] of char;
  s : string;
  mistake : boolean;

procedure Put(c:char);
begin
  inc(current);
  a[current]:=c;
end;

function Top : char;
begin
  Top := a[current];
end;

procedure Take;
begin
  dec(current);
end;

function IsEmpty : boolean;
begin
  if current = 0 then IsEmpty:=True
  else IsEmpty := False;
end;

begin
  assign(Input,'brackets.in');reset(Input);
  assign(Output,'brackets.out');rewrite(Output);
  current := 0;
  read(s);
  i:=1;
  mistake:=False;
  while (i<=length(s)) AND not mistake do begin
    if s[i] in ['(','[','{'] then
      Put(s[i])
    else
      if IsEmpty then
        mistake := True
      else
        if (s[i]=')') AND (Top='(') OR
           (s[i]=']') AND (Top='[') OR
           (s[i]='}') AND (Top='{') then
          take
        else
          mistake := true;
    inc(i);
  end;
  if not IsEmpty then mistake := True;
  if mistake then write('NO') else write('YES');
  close(Input);close(Output);
end.