n = int(input()) s = list(input()) dp = [0]*(n//2+1) ans = 1 dp[0] = 1 cnt = 0 mod = 998244353 for ii,e in enumerate(s): n_dp = [0]*(n//2+1) if e == "(": cnt += 1 for i in range(n//2+1): n_dp[i] += dp[i] n_dp[i] %=mod if i < n//2: n_dp[i+1] += dp[i] n_dp[i+1] %=mod else: cnt -= 1 for i in range(n//2+1): if i <= cnt: n_dp[i] += dp[i] n_dp[i] %= mod if i > 0: n_dp[i-1] += dp[i] n_dp[i-1] %= mod dp = n_dp # print(dp) print(dp[0]%mod)