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

public class Brackets {
    public static void main(String[] args) throws Exception{
        Scanner in = new Scanner(new File("brackets.in"));
        PrintWriter out = new PrintWriter("brackets.out");
        String s = in.next();
        LinkedList stack = new LinkedList<Character>();
        for (int i = 0; i < s.length(); i++){
            if ((s.charAt(i)=='(')||(s.charAt(i)=='[')||(s.charAt(i)=='{')){
                stack.add(s.charAt(i));
            } else {
                if ((s.charAt(i)==')')&&(stack.getLast().equals('('))){
                    stack.remove(stack.size()-1);
                } else if ((s.charAt(i)==']')&&(stack.getLast().equals('['))){
                    stack.remove(stack.size()-1);
                } else if ((s.charAt(i)=='}')&&(stack.getLast().equals('{'))){
                    stack.remove(stack.size()-1);
                }
            }
        }
        if (stack.size() == 0){
            out.print("YES");
        } else out.print("NO");
        in.close();
        out.close();
    }
}