import java.util.Scanner;
import java.util.LinkedList;
import java.io.File;
import java.io.PrintWriter;

/**
 * Created by IntelliJ IDEA.
 * User: m09fpv
 * Date: 25.11.2009
 * Time: 17:11:37
 * To change this template use File | Settings | File Templates.
 */
public class brackets {
 static char[] b = {'(', '[','{','}',']',')'};
  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> a=new LinkedList<Character>();
   String s;
   s=in.next();
   int t=s.length();
   char[] b=s.toCharArray();
 for(int i=0;i<t;i++){
   if(b[i]=='('){
     if(b[i+1]==']'||b[i+1]=='}'){ out.print("NO"); System.exit(0); }
     a.addLast(b[i]);
    }
   if(b[i]=='['){
     if(b[i+1]==')'||b[i+1]=='}'){ out.print("NO"); System.exit(0); }
     a.addLast(b[i]);
    }
   if(b[i]=='{'){
     if(b[i+1]==']'||b[i+1]==')'){ out.print("NO"); System.exit(0); }
     a.addLast(b[i]);
    }
   if(b[i]==')'){
     if(a.getLast()=='('){ a.removeLast(); }
     else{a.addLast(b[i]); }
    }
   if(b[i]==']'){
     if(a.getLast()=='['){ a.removeLast(); }
     else{a.addLast(b[i]); }
    }
   if(b[i]=='}'){
     if(a.getLast()=='{'){ a.removeLast(); }
     else{a.addLast(b[i]); }
    }
}
  if(a.size()==0){ out.print("YES"); }
  else { out.print("NO"); }
  in.close();
  out.close();
   }
}
