#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXSIZE 100
typedef struct SNode
{
char data;
struct SNode* next;
}SNode;
int push(SNode* pS, char a)
{
SNode* pR;
pR = (SNode*)malloc(sizeof(SNode));
pR->data = a;
pR->next = pS->next;
pS->next = pR;
}
int pop(SNode* pS)
{
char t;
SNode* pR;
pR = pS->next;
if (pS->next == NULL)
return 0;
t = pR->data;
pS->next = pR->next;
free(pR);
return t;
}
int opLinkStack(SNode* pS, char a[])
{
int len, i = 0, t, flag = 1;
len = strlen(a);
for (i = 0; i < len; i++)
{
if (a[i] == '(' || a[i] == '[')
push(pS, a[i]);
else if (a[i] == ')' || a[i] == ']')
{
t = pop(pS);
if (t == 0)
{
flag = 0;
return flag;
}
else
{
if (a[i] == ')' && t == '(')
flag = 1;
else if (a[i] == ']' && t == '[')
flag = 1;
else
{
flag = 0;
return flag;
}
}
}
}
if (pS->next != NULL)
flag = 0;
return flag;
}
int main()
{
char a[MAXSIZE];
SNode* pS;
pS = (SNode*)malloc(sizeof(SNode));
pS->next = NULL;
scanf("%s", a);
if (opLinkStack(pS, a) == 1)
printf("YES");
else
printf("NO");
return 0;
}