def balanced(express):
stack = []
matching = {')': '(', ']': '['}
for char in express:
if char in matching.values():
stack.append(char)
elif char in matching:
if not stack or stack.pop() != matching[char]:
return 0
return 1 if not stack else 0
express = input().strip()
print(balanced(express))
2.
input_data = list(map(int, input().split(',')))
duration = input_data[0]
tasks = input_data[1:]
dp = [0] * (duration + 1)
dp[0] = 1
for task in tasks:
for i in range(duration, task - 1, -1):
dp[i] += dp[i - task]
print(dp[duration])