n = int(input()) S = input() mod = 998244353 dp = [0]*(n+1) dp[0] = 1 count = 0 for s in S: ndp = [0]*(n+1) ad = 1 if s == "(" else -1 for i in range(n+1): if dp[i] == 0: continue if 0 <= i+ad <= n: ndp[i+ad] += dp[i] ndp[i+ad] %= mod if 0 <= count-i+ad <= n: ndp[i] += dp[i] ndp[i] %= mod dp = ndp count += ad ans = 0 if count == 0: ans = dp[0] print(ans)