#include using namespace std; using ll = long long; int main () { ll m = 998244353; int N; string s; cin >> s; N = s.size(); ll dp[3030][3030]; for (int i = 0; i <= N; i ++) { for (int j = 0; j <= N; j ++) { dp[i][j] = 0; } } dp[0][0] = 1; int now = 0; for (int i = 1; i <= N; i ++) { int x = (s[i - 1] == '(' ? 1 : -1); now += x; for (int j = 0; j <= now; j ++) { dp[i][j] = dp[i - 1][j]; if (0 <= j - x && j - x <= N) { dp[i][j] += dp[i - 1][j - x]; dp[i][j] %= m; } } } cout << dp[N][0] << endl; }