#include const int Mod = 998244353; int naive(char s[]) { int l; for (l = 0; s[l] != 0; l++); if (l % 2 != 0) return 0; long long dp[1001][2002] = {}, tmp; int i, j, k, ll = l / 2; for (k = 0, dp[0][0] = 1; k < ll; k++) { if (s[k] == '(') { for (i = 0; i <= k / 2; i++) { for (j = i * 2 + k % 2; j <= k; j += 2) { tmp = dp[i][j] % Mod; dp[i][j] = 0; dp[i][j+1] += tmp; } } } else if (s[k] == ')') { for (i = 0; i <= k / 2; i++) { for (j = i * 2 + k % 2; j <= k; j += 2) { tmp = dp[i][j] % Mod; dp[i][j] = 0; if (j > i * 2) dp[i][j-1] += tmp; else if (i > 0) dp[i-1][j-1] += tmp; } } } else if (s[k] == '?') { for (i = 0; i <= k / 2; i++) { for (j = i * 2 + k % 2; j <= k; j += 2) { tmp = dp[i][j] % Mod; dp[i][j] = 0; if (j > i * 2) dp[i+1][j+1] += tmp; else dp[i][j+1] += tmp; } } } else { for (i = 0; i <= k / 2; i++) { for (j = i * 2 + k % 2; j <= k; j += 2) { tmp = dp[i][j] % Mod; dp[i][j] = 0; dp[i][j+1] += tmp; if (j > i * 2) { dp[i][j-1] += tmp; dp[i+1][j+1] += tmp; } else { if (i > 0) dp[i-1][j-1] += tmp; dp[i][j+1] += tmp; } } } } } long long dpp[1001][2002] = {}; for (k = 0, dpp[0][0] = 1; k < ll; k++) { if (s[l-k-1] == ')') { for (i = 0; i <= k / 2; i++) { for (j = i * 2 + k % 2; j <= k; j += 2) { tmp = dpp[i][j] % Mod; dpp[i][j] = 0; dpp[i][j+1] += tmp; } } } else if (s[l-k-1] == '(') { for (i = 0; i <= k / 2; i++) { for (j = i * 2 + k % 2; j <= k; j += 2) { tmp = dpp[i][j] % Mod; dpp[i][j] = 0; if (j > i * 2) dpp[i][j-1] += tmp; else if (i > 0) dpp[i-1][j-1] += tmp; } } } else if (s[l-k-1] == '?') { for (i = 0; i <= k / 2; i++) { for (j = i * 2 + k % 2; j <= k; j += 2) { tmp = dpp[i][j] % Mod; dpp[i][j] = 0; if (j > i * 2) dpp[i+1][j+1] += tmp; else dpp[i][j+1] += tmp; } } } else { for (i = 0; i <= k / 2; i++) { for (j = i * 2 + k % 2; j <= k; j += 2) { tmp = dpp[i][j] % Mod; dpp[i][j] = 0; dpp[i][j+1] += tmp; if (j > i * 2) { dpp[i][j-1] += tmp; dpp[i+1][j+1] += tmp; } else { if (i > 0) dpp[i-1][j-1] += tmp; dpp[i][j+1] += tmp; } } } } } long long ans = 0, dpp_sum[2][2003] = {}; for (i = 0; i <= ll / 2; i++) { for (j = i * 2 + ll % 2; j <= ll; j += 2) { dpp_sum[0][j] += dpp[i][j]; dpp_sum[1][j-i*2] += dpp[i][j]; } } for (j = ll % 2 + 2; j <= ll; j += 2) dpp_sum[0][j] += dpp_sum[0][j-2]; for (j = ll - 2; j >= 0; j -= 2) dpp_sum[1][j] += dpp_sum[1][j+2]; for (i = 0; i <= ll / 2; i++) { for (j = i * 2 + ll % 2; j <= ll; j += 2) { if (j == i * 2 + ll % 2) ans += dp[i][j] * ((dpp_sum[0][ll] - dpp_sum[1][j+2]) % Mod) % Mod; else ans += dp[i][j] * ((dpp_sum[0][ll] - dpp_sum[0][j-i*2-2] - dpp_sum[1][j+2]) % Mod) % Mod; } } return ans % Mod; } int main() { int i; char s[4001]; scanf("%s", s); printf("%d\n", naive(s)); fflush(stdout); return 0; }