def main(): import sys sys.setrecursionlimit(1 << 25) h = sys.stdin.readline().strip() memo = {} def grundy(s): if s in memo: return memo[s] if not s: return 0 # Try to split as s' + "()" first # Find the last occurrence of "()" as possible stack = [] last_pos = -1 for i, c in enumerate(s): if c == '(': stack.append(i) else: if stack: start = stack.pop() if i == start + 1: last_pos = start if last_pos != -1: s_prime = s[:last_pos] g = grundy(s_prime) memo[s] = g + 1 return g + 1 # Otherwise, split as s0 + "(s1)" # Find the first possible split stack = [] for i, c in enumerate(s): if c == '(': stack.append(i) else: if stack: start = stack.pop() if start == 0: s0 = s[:start] s1 = s[start+1:i] g0 = grundy(s0) g1 = grundy(s1) mex = 0 seen = set() seen.add(g0 ^ (g1 + 1)) while mex in seen: mex += 1 memo[s] = mex return mex # If neither can be split, it's dead memo[s] = 0 return 0 g = grundy(h) if g == 0: print(1) else: print(0 if g % 2 == 1 else 1) if __name__ == "__main__": main()