/**
 * Created by IntelliJ IDEA.
 * User: m09dam
 * Date: 25.11.2009
 * Time: 17:11:53
 * To change this template use File | Settings | File Templates.
 */
import java.util.*;
import java.io.*;
public class Problem_A_25_11_09 {
    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> p = new LinkedList<Character>();
        String s = in.next();
        char[] c = s.toCharArray();
        int i = 0 ;
        for(i=0;i< s.length();i++){
            if ((c[i]=='(')||(c[i]=='[')||(c[i]=='{')){
                p.addLast(c[i]);
            }
            if (p.isEmpty()){out.print("NO");break;}
            if ((c[i]==')')&&(p.getLast()=='(')){p.removeLast();}
            if ((c[i]=='}')&&(p.getLast()=='{')){p.removeLast();}
            if ((c[i]==']')&&(p.getLast()=='[')){p.removeLast();}
        }
        if(i==s.length()){if(p.isEmpty()){out.print("YES");}
        else{out.print("NO");};
        }
        out.close();
        in.close();
    }
}
