#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

#define FOR(i,st,en) for (int i=st;i<en;i++)
#define REP(i,en) FOR(i,0,en)
#define SZ(x) (int)x.size()
#define FORD(i,x) REP(i,SZ(x))
#define all(x) x.begin(),x.end()

int main( ){
    freopen("brackets.in", "r", stdin);
    freopen("brackets.out","w", stdout);
    string s;
    cin>> s;
    stack <char> st;
    bool error = false;
    FORD(i, s){
        if (s[i] == '}'){
            if (st.empty() || st.top()!='{')
                error = true; else
                st.pop();
        } else
        if (s[i] == ']'){
            if (st.empty() || st.top()!='[')
                error = true; else
                st.pop();
        }else
        if (s[i] == ')'){
            if (st.empty() || st.top()!='(')
                error = true; else
                st.pop();
        } else
        st.push(s[i]);
    }
    error = error || (st.empty() == false);
    if (error){
        cout<<"NO";
    } else {
        cout<<"YES";
    }
}
