


밸런스 부분을 고려하지 못해서 푸는 데 시간이 꽤 걸렸다. 나중에 다시 풀어볼 예정
while True:
line = input().rstrip()
if line == '.':
break
stack = []
balance = True
for i in line:
if i in '([':
stack.append(i)
elif i in '])':
if not stack:
balance = False
break
stack_pop = stack.pop()
if (stack_pop == '[' and i != ']') or (stack_pop == '(' and i != ')'):
balance = False
if balance and not stack:
print('yes')
else:
print('no')