#include
#include
using namespace std;
int main()
{
char c[100],c1[100],top=-1;
cin>>c;
for(int i=0;i<strlen(c);i++){
if(c[i]=='('||c[i]=='['){
c1[++top]=c[i];
}else if(c[i]==')'&&c1[top]=='('){
top--;
}else if(c[i]==']'&&c1[top]=='['){
top--;
}else{
cout<<"NO";
return 0;
}
}
if(top==-1){
cout<<"YES";
}else{
cout<<"NO";
}
return 0;
}