#include <iostream>
#include <vector>
#include <stack>
using namespace std;

int main()
{
  string o;
  cin>>o;
  stack<char>p;
  for(int y=0; y<o.size(); y+=1){
      if(o[y] == '(' or o[y] == '{' or o[y] == '[') {
          p.push(o[y]);
      }
      else {
          if(o[y] == ')' and  !p.empty() and p.top() == '(') {
              p.pop();
          }
          else if(o[y] == '}' and !p.empty() and p.top() == '{') {
              p.pop();
          }
          else if(o[y] == ']' and !p.empty() and p.top() == '[') {
              p.pop();
          }
          else {
              cout << "NO" << endl;
              return 0;
          }
      }
            
    }

        

    if(p.empty()) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
   
    
    
    
    return 0;
}
// ]]][[[[
