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();boolean res=true;
        int i=0;
        while((i<s.length())&&res){
            res=false;
            if(s.charAt(i) == '{'|s.charAt(i) == '['|s.charAt(i) == '('){
                stack.addFirst(s.charAt(i));res=true;
            }else if((s.charAt(i) == '}'& stack.getFirst()=='{')|
                     (s.charAt(i) == ']'& stack.getFirst()=='[')|
                     (s.charAt(i) == ')'& stack.getFirst()=='(')){
                stack.removeFirst();res=true;
            }
            i++;
        }
        out.println((stack.size()==0&&res)?"YES":"NO");
        out.close();
    }
}
