mod = 998244353 n = int(input()) s = input() dp = [[0] * (n+1) for i in range(n+1)] dp[0][0] = 1 tmp = 0 for i in range(n): if s[i] == "(": tmp += 1 for j in range(n+1): if j+1 <= n: dp[i+1][j+1] += dp[i][j] dp[i+1][j+1] %= mod if tmp-j >= 0: dp[i+1][j] += dp[i][j] dp[i+1][j] %= mod else: tmp -= 1 for j in range(n+1): if j-1 >= 0: dp[i+1][j-1] += dp[i][j] dp[i+1][j-1] %= mod if tmp-j >= 0: dp[i+1][j] += dp[i][j] dp[i+1][j] %= mod print(dp[n][0])