t = input()
a = 0
Left_bracket_Z=0
Right_bracket_Z=0
for i in t:
if i== '(':
a+=1
elif i== ')':
if a>0:
a-=1
else:
print("配对不成功")
break
elif i=='[':
Left_bracket_Z+=1
elif i==']':
Right_bracket_Z+=1
else:
if a!=0:
print("配对不成功")
elif Left_bracket_Z!=Right_bracket_Z:
print("配对不成功")
else:
print("配对成功")