'''
n = int(input())
res = []
class stk:
data = []
cnt = 0
def __init__(self):
print("")
def __init__(self, data):
self.data = data
def excute(self):
for i in range(len(self.data)):
if self.data[i] == "(":
self.input()
else:
self.output()
if self.cnt < 0:
return 'NO'
if self.cnt!=0:
return 'NO'
else:
return 'YES'
def input(self):
self.cnt += 1
def output(self):
self.cnt -= 1
for i in range(n):
v = input()
x = stk(v)
res.append(x.excute())
for i in range(len(res)):
print(res[i])
'''
'''
class stk:
data = []
data1 = list(data)
c = 0
cnt = 0
pnt = 0
def __init__(self):
def __init__(self, data):
self.data = data
self.data1 = list(data)
def excute(self):
for i in range(len(self.data)):
if self.data[i] == '(':
self.input()
self.data1[self.c] = '('
self.c += 1
elif self.data[i] == '[':
self.input1()
self.data1[self.c] = '['
self.c += 1
elif self.data[i] == ')':
self.output()
if self.data1[self.c] != '(' or self.cnt<0:
return 'NO'
elif self.data1[self.c]=='(':
self.c -= 1
elif self.data[i] == ']':
self.output1()
if self.data1[self.c] != '[' or self.pnt<0:
return 'NO'
elif self.data1[self.c]=='[':
self.c -= 1
if self.cnt == 0 and self.pnt==0:
return 'YES'
else:
return 'NO'
def input(self):
self.cnt += 1
def output(self):
self.cnt -= 1
def input1(self):
self.pnt += 1
def output1(self):
self.pnt -= 1
res = []
while(True):
v = input()
if v =='.':
break
x = stk(v)
res.append(x.excute())
for i in range(len(res)):
print(res[i])
'''
res = []
while(True):
v = input()
if v == '.':
break
stk = []
cnt = 0
sta = True
for i in v :
if i == '[' or i == '(':
stk.append(i)
cnt += 1
elif i == ']':
if stk != '[' or cnt == 0:
sta = False
break
cnt -= 1
stk.pop()
elif i == ')':
if stk != '(' or cnt == 0:
sta = False
break
cnt -= 1
stk.pop()
if sta == True:
print("yes")
else:
print("no")