#1括号匹配问题
s=input()
match={"]":"[",")":"("}
stack=[]
i=len(s)
for ch in s:
if ch in ["(","["]:
stack.append(ch)
else:
if stack==[]:
i=i
elif stack[-1] == match[ch]:
stack.pop()
i=i-2
else:
i=i
print(i)
#2分组队长问题
def rec(n,m):
if m == n:
return 1
elif m == 1:
return n
else:
return rec(n-1,m-1)+rec(n-1,m)
a=input()
n=int(a)
num=0
i=1
while i<=n:
num=num+i*rec(n,i)
i+=1
num1=num%(1e9+7)
print(num1)
#3积分运算
from scipy import integrate
def f(x):
return x + 1
v, err = integrate.quad(f, 1, 2)
print(v)
a=input()
b=input()
A=int(b[0])
B=int(b[2])
C=int(b[4])
D=int(b[6])
S=1/3*(D-C)**3+1/2*(D-C)**2+B*(D-C)