s = input()
stack =[]
for c in s:
    if c =='[' or c =='(':
        stack.append(c)
    elif c ==']'or c ==')':
        if len(stack) ==0:
            print('false')
            exit()
        top = stack.pop()
        if c == ']' and top!='[':
            print('false')
            exit() 
        if c == ')' and top!='(':
            print('false')
            exit() 
    else:
        continue
if len(stack) == 0:
    print('true')
else:
    print('false')