MOD = 998244353 S = input() n = len(S) dp = [[0] * 2 for _ in range(n)] dp[0][0] = 1 for s in S: ndp = [[0] * 2 for _ in range(n)] def f1(): for i in range(n - 1): ndp[i + 1][0] += dp[i][0] ndp[i + 1][1] += dp[i][1] ndp[i + 1][0] %= MOD ndp[i + 1][1] %= MOD def f2(): for i in range(n - 1): ndp[i][0] += dp[i + 1][0] ndp[i][1] += dp[i + 1][1] ndp[i][0] %= MOD ndp[i][1] %= MOD def f3(): for i in range(n - 1): ndp[i + 1][0] += dp[i][0] ndp[i + 1][0] %= MOD ndp[i][1] += dp[i + 1][1] + dp[i + 1][0] ndp[i][1] %= MOD if s == "(": f1() elif s == ")": f2() elif s == "?": f3() else: f1() f2() f3() dp = ndp ans = dp[0][0] + dp[0][1] print(ans % MOD)