import java.util.*;
import java.io.*;

/**
 * Created by IntelliJ IDEA.
 * User: o_215
 * Date: 25.11.2009
 * Time: 17:14:50
 * To change this template use File | Settings | File Templates.
 */
public class A {
    public static void main(String[] args) throws Exception{
        Scanner in=new Scanner(new File("brackets.in"));
        PrintWriter out=new PrintWriter(new File("brackets.out"));
        LinkedList<Character> stack=new  LinkedList<Character>();
        String s=in.nextLine();
        for(int i=0;i<s.length();i++){
            char l=s.charAt(i);
            if(l==('{'|'['|'(')){
                stack.addFirst(l);
            }else if(stack.size()!=0){
                if((l=='{'&'}'==stack.getFirst())|
                        (l=='['&']'==stack.getFirst())|
                        (l=='('&')'==stack.getFirst())){
                    stack.removeFirst();
                }
            }else{
                    out.println("NO");out.close(); System.exit(0);

            }
        }
        out.println((stack.size()==0)?"YES":"NO");
        out.close();
    }
}
