You are given a bracket sequence s consisting of n opening '(' and closing ')' brackets.

A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of the sequence. For example, bracket sequences "()()", "(())" are regular (the resulting expressions are: "(1)+(1)", "((1+1)+1)"), and ")(" and "(" are not.

You can change the type of some bracket s_i. It means that if s_i =  ')' then you can change it to '(' and vice versa.

Your task is to calculate the number of positions i such that if you change the type of the i-th bracket, then the resulting bracket sequence becomes regular.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 10^6) — the length of the bracket sequence.

The second line of the input contains the string s consisting of n opening '(' and closing ')' brackets.

Output

Print one integer — the number of positions i such that if you change the type of the i-th bracket, then the resulting bracket sequence becomes regular.

Examples

Input


6
(((())


Output


3


Input


6
()()()


Output


0


Input


1
)


Output


0


Input


8
)))(((((


Output


0
from typing import *


def main():
  n = int(input())
  s = input().strip()
  ans = solve(n, s)
  print(ans)


def solve(n: int, s: str) -> int:
  if n % 2 == 1:
    return 0
  if s[0] == ')' and s[-1] == '(':
    return 0
  num_closing = s.count(')')
  num_opening = s.count('(')

  if abs(num_closing-num_opening) != 2:
    return 0
  if num_closing < num_opening:
    return solve_switch_opening(n, s)
  else:
    return solve_switch_closing(n, s)


def transform(s: str) -> List[int]:
  acc, transformed = 0, []
  for c in s:
    acc += 1 if c == '(' else -1
    transformed.append(acc)
  return transformed



def solve_switch_opening(n: int, s: str) -> int:
  s_trans = transform(s)
  if len([x for x in s_trans if x < 0]) > 0:
    return 0
  switchable_min_idx = n
  for i in range(n-1, -1, -1):
    si = s_trans[i]
    if si < 2:
      break
    switchable_min_idx = i
  num_switchables = 0
  for i in range(switchable_min_idx, n):
    if s[i] == '(':
      num_switchables += 1
  return num_switchables


def solve_switch_closing(n: int, s: str) -> int:
  s_trans = transform(s)
  if len([x for x in s_trans if x < -2]) > 0:
    return 0
  switchable_max_idx = -1
  for i in range(n):
    si = s_trans[i]
    switchable_max_idx = i
    if si < 0:
      break
  num_switchables = 0
  for i in range(0, switchable_max_idx+1):
    if s[i] == ')':
      num_switchables += 1
  return num_switchables


main()
