#include<stdio.h>
#include<string.h>

int main(void){
  char str[128];
  int i,check1,check2,scount,mcount,l;
  while(fgets(str,sizeof(str),stdin)){
    check1=check2=scount=mcount=0;
    if(str[0]=='.') return 0;
    l=strlen(str);
    for(i=0;i<l;i++){
      if(str[i]=='(') scount++,check1=1;
      if(str[i]==')'){
	scount--;
	if(check1==0) break;
      }
      if(str[i]=='[') mcount++,check2=1;
      if(str[i]==']'){
	mcount--;
	if(check2==0) break;
      }
      //printf("%d %d\n",scount,mcount);
    }
    if(scount==0&&mcount==0) puts("YES");
    else puts("NO");
  }
  return 0;
}
 