H = input().strip() max_depth = 0 count = 0 current_depth = 0 i = 0 n = len(H) while i < n: if H[i] == '(' and i + 1 < n and H[i+1] == ')': depth = current_depth if depth > max_depth: max_depth = depth count = 1 elif depth == max_depth: count += 1 i += 2 else: if H[i] == '(': current_depth += 1 else: current_depth -= 1 i += 1 if count % 2 == 1: print(0) else: print(1)