import java.io.*;

import java.util.*;

public class Main{
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(new File("brackets.in"));
        PrintWriter p = new PrintWriter(new File("brackets.out"));
        String str = s.nextLine();
        boolean pos = true;
        Stack<Character> st = new Stack<Character>();
        for(int i = 0; i < str.length(); i++){
            char c = str.charAt(i);
            if(c =='(' || c=='[' || c=='{'){
                st.push(c);
            }
            else{
                if(st.size() == 0){
                    pos = false;
                    break;
                }
                if(Math.abs(c - st.pop())>2 ) {
                    pos = false;
                    break;
                }
            }
        }
        if(st.size()!=0) pos = false;
        if(pos) p.println("YES"); else p.println("NO");
        p.close();
    }

}