/**
 * Created by IntelliJ IDEA.
 * User: m09aaa
 * Date: 25.11.2009
 * Time: 17:09:02
 * To change this template use File | Settings | File Templates.
 */
import java.util.*;
import java.io.*;
public class Brackets {
    static boolean Sootv(char c1, char c2)
    {
        if ((c1=='('&&c2==')')||(c1=='['&&c2==']')||(c1=='{'&&c2=='}'))
        {return true;}
       else { return false;}
    }
    public static void main(String [] args) throws Exception{
        Scanner in=new Scanner(new File("brackets.in"));
        LinkedList<Character> stack=new LinkedList<Character>();
        String s=in.nextLine();
        boolean right=false;
        int i=0;
        while (i<s.length())
        {
            if (s.charAt(i)=='('||s.charAt(i)=='['||s.charAt(i)=='{')
            {
                stack.addLast(s.charAt(i));
            }
            else
            {
                if (i!=0&&stack.size()!=0&&Sootv(stack.getLast(),s.charAt(i)))
                {
                stack.removeLast();
                }
                else
                {
                    i=s.length();
                }
            }
            i++;
        }
        if (i!=s.length()+1&&stack.size()==0)
        {
            right=true;
        }
        PrintWriter out=new PrintWriter(new File("brackets.out"));
        if (right)
        {
            out.println("YES");
        }
        else
        {
            out.println("NO");
        }
        out.close();
    }
}
