#include
#include
int main()
{
int i,count;
char ch[10001],ch1[10001];
while(gets(ch)!=NULL)
{
count=-1;
for(i=0;ch[i]!='\0';i++)
{
if(ch[i]=='('||ch[i]=='['||ch[i]=='<'||ch[i]=='{')
{
ch1[++count]=ch[i];
}
else
{
if(ch[i]-ch1[count]<3)
{
count--;
}
else
{
break;
}
}
}
if(count==-1)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}