print("Введите скобчатую последовательность")
z =input()
z1,z2,z3,z4,z5,z6,z7,z8 = "","","","","","","",""
for y in z:
    if y == '(':
        z1 += y
    if y == ')':
        z2 += y
        if len(z1) > 0:
            if z1[-1] == '(':
                z1 = z1[:-1]
                z2 = z2[:-1]
    if y == '[':
        z3 += y
    if y == ']' :
        z4 += y
        if len(z3) > 0:
            if z3[-1] == '[':
                z3 = z3[:-1]
                z4 = z4[:-1]
    if y == '{':
        z5 += y
    if y == '}':
        z6 += y
        if len(z5) > 0:
            if z5[-1] == '{':
                z5 = z5[:-1]
                z6 = z6[:-1]
    if y == '<':
        z7 += y
    if y == '>' :
        z8 += y
        if len(z7) > 0:
            if z7[-1] == '<':
                z7 = z7[:-1]
                z8 = z8[:-1]
if len(z1) == 0 and len(z2) == 0 and len(z3) == 0 and len(z4) == 0 and len(z5) == 0 and len(z6) == 0 and len(z7) == 0 and len(z8) == 0:
    print("True")
else:
    print("False")