#include
#include
using namespace std;
typedef char Element;
class SeqStack{
public :
int MaxSize;
Element *elements;
int top;
int length;
SeqStack(Element *e,int Size)
{
top=-1;
length=0;
elements=e;
MaxSize=Size;
}
int PushSeqStack(Element element);
void PopSeqStack();
void ClearSeqStack();
Element PeekSqeStack();
};
/** 向栈中压入元素,返回压入的结果(true/false) */
int SeqStack::PushSeqStack(Element element){
if(top == MaxSize- 1){
cout<<"栈已满"<<endl;
}
top++; //栈顶指针+1,以便加.01 004入新的元素
//将新插入的元素赋值给栈顶
elements[top] = element;
length++;
}
Element SeqStack::PeekSqeStack()
{
return elements[top];
}
void SeqStack::PopSeqStack(){
//返回栈顶指向的元素
//*element = elements[top];
//cout<<"弹出元素"<<elements[top]<<endl;
top--;
length--;
}
void SeqStack::ClearSeqStack(){
top = -1;
length = 0;
}
int main()
{
Element* e=new Element[100];
bool IsOk=true;
SeqStack Stack(e,100);
string s;
while(!cin.eof())
{
cin>>s;
Stack.ClearSeqStack();
for(int i=0;i<s.size();i++)
{
if(s[i]=='('||s[i]=='{'||s[i]=='[')
{
Stack.PushSeqStack(s[i]);
}
else if(s[i]==']'||s[i]==')'||s[i]=='}')
{
if((Stack.PeekSqeStack()=='('&&s[i]==')')||(Stack.PeekSqeStack()=='{'&&s[i]=='}')||(Stack.PeekSqeStack()=='['&&s[i]==']'))
{
Stack.PopSeqStack();
}
else
{
IsOk=false;
}
}
}
if(IsOk==false)
{
cout<<"NO"<<endl;
IsOk=true;
continue;
}
if(Stack.top==-1)
{
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}
return 0;
}