#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main ()
{
string s;
int i;
char a;
stack<char>st;
while(cin>>s){
while(!st.empty())st.pop(); //清空栈
for(i=0;i<s.size();i++){
a=s[i];
if(a=='{'||a=='['||a=='(')
st.push(a);
else
{
if(st.empty())
{
st.push(a);break;
}
else if(a=='}'){
if(st.top()=='{')
st.pop();
}
else if(a==')'){
if(st.top()=='(')
st.pop();
}
else if(a==']'){
if(st.top()=='[')
st.pop();
}
}
}
if(!st.empty())cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}