def is_correct(s): stack = [] for v in s: stack.append(v) if len(stack) >= 2 and stack[-2] == '(' and stack[-1] == ')': stack.pop() stack.pop() if not stack: return True else: return False def solve(n, s): mod = 998244353 if not is_correct(s): return 0 open = [0] * n close = [0] * n for i in range(n): if s[i] == '(': open[i] += 1 else: close[i] += 1 open[i] += open[i - 1] close[i] += close[i - 1] dp = [0] * (n + 1) dp[0] = 1 for i in range(n): e = [0] * (n + 1) a = open[i] - close[i] if s[i] == '(': for j in range(i + 1): e[j + 1] += dp[j] e[j] += dp[j] else: for j in range(i + 1): if j >= 0: e[j - 1] += dp[j] if a - j >= 0: e[j] += dp[j] dp = [i % mod for i in e] return dp[0] import sys input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) INF = 2 ** 63 - 1 mod = 998244353 n = ii() s = input() print(solve(n, s))