#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[2003][4003] = {}, tmp; int i, j, k, ll = l / 2; for (k = 0, dp[0][0] = 1; k < l; k++) { if (s[k] == '(') { for (i = 0; i <= k / 2; i++) { for (j = i * 2 + k % 2; j <= k; j += 2) { if (dp[i][j] == 0) continue; 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) { if (dp[i][j] == 0) continue; 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) { if (dp[i][j] == 0) continue; 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) { if (dp[i][j] == 0) continue; tmp = dp[i][j] % Mod; dp[i][j] = 0; dp[i][j+1] += tmp; if (j > i * 2) dp[i][j-1] += tmp; else if (i > 0) dp[i-1][j-1] += tmp; if (j > i * 2) dp[i+1][j+1] += tmp; else dp[i][j+1] += tmp; } } } } long long ans = 0; for (i = 0; i <= ll; i++) ans += dp[i][i*2]; return ans % Mod; } int main() { char s[4001]; scanf("%s", s); printf("%d\n", naive(s)); fflush(stdout); return 0; }