#include #include using namespace std; using namespace atcoder; using mint = modint998244353; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; string s; cin >> s; vector dp(n + 1); dp[0] = 1; int sum = 0; for (char c : s) { sum += (c == '(' ? 1 : -1); vector cur(n + 1); for (int j = 0; j <= sum; j++) { cur[j] = dp[j]; if (j > 0 || c == ')') { cur[j] += dp[j - (c == '(' ? 1 : -1)]; } } dp = cur; } cout << dp[0].val(); }