var s:string; stack:array[0..240] of char; i,j,n,e:longint; no:boolean; Begin Assign(input,'input.txt'); reset(input); Assign(output,'output.txt'); rewrite(output); readln(s); for i:=1 to length(s) do if (s[i]='(') or (s[i]='{') or (s[i]='[') then begin inc(e); if s[i]='(' then stack[e]:=')' else if s[i]='{' then stack[e]:='}' else stack[e]:=']'; end else if (stack[e]<>s[i]) then no:=true else dec(e); if (e<>0) or (no) then write('Нет') else write('Да'); end.