#include<bits/stdc++.h>
using namespace std;
char a[1010101];
int top;
bool pan(string s)
{
for(int i=0;i<s.size();i++)
{
if(s[i]=='(' || s[i]=='[')
{
a[++top]=s[i];
}
else
{
if(top==0)return false;
if(s[i]-a[top]==1 || s[i]-a[top]==2)top--;
else return false;
}
}
if(top)return false;
return true;
}
int main()
{
string s;
cin>>s;
if(pan(s))cout<<"YES";
else cout<<"NO";
return 0;
}
不知为何WA60分。