mod = 998244353 def main(): import sys input = sys.stdin.readline N = int(input()) S = input().rstrip('\n') dp = [0] * (N + 1) dp[0] = 1 total_balance = 0 for i, s in enumerate(S): if s == "(": d = 1 else: d = -1 dp_new = [0] * (2 * N + 1) for j in range(N + 1): k = total_balance - j if 0 <= j + d <= N: dp_new[j + d] = (dp_new[j + d] + dp[j]) % mod if 0 <= k + d <= N: dp_new[j] = (dp_new[j] + dp[j]) % mod total_balance += d dp = dp_new print(dp[0]) if __name__ == '__main__': main()