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

class Brackets implements Runnable{
    public void run(){
             try{
                 Scanner in = new Scanner(new File("brackets.in"));
                 PrintWriter out = new PrintWriter(new File("brackets.out"));
                 boolean res = true;

                 LinkedList<Integer> m = new LinkedList<Integer>();
                 String s = in.next();
                 for(int i = 0; i < s.length() && res; i++)
                 {
                     char c = s.charAt(i);
                     if(c == '(' || c == '{' || c == '[')
                        m.addLast(c - '0');
                     else{
                         if(m.isEmpty())
                           res = false;
                         else {
                             int l = m.getLast();
                             if(l == c - '0'-2  || l == c - '0'-1)
                               m.removeLast();
                             else res = false;
                         }
                     }
                 }
                 if(res && m.isEmpty()) out.write("YES");
                 else  out.write("NO");

                 in.close();
                 out.close();
             }  catch(Exception e){
                  e.printStackTrace();
                  System.exit(1);
                }
           }
           public static void main(String[] args) {
              new Thread(new Brackets()).start();
           }

}
