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