#include <bits/stdc++.h>
using namespace std;
const long long N = 2005;
const long long mod = 998244353;
string s;
long long n;
long long dp[N][N];
long long sumq[N], p2[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  n = s.size();
  sumq[0] = (s[0] == '?');
  for (long long i = (long long)1; i <= (long long)n - 1; i++)
    sumq[i] = sumq[i - 1] + (s[i] == '?');
  p2[0] = 1;
  for (long long i = (long long)1; i <= (long long)N - 5; i++)
    p2[i] = p2[i - 1] * 2 % mod;
  for (long long len = (long long)2; len <= (long long)n; len++) {
    for (long long l = 0, r = len - 1; r < n; l++, r++) {
      auto& ret = dp[l][r];
      if (s[l] != '(') ret = (ret + dp[l + 1][r]) % mod;
      if (s[r] != ')') ret = (ret + dp[l][r - 1]) % mod;
      if (s[l] != '(' && s[r] != ')') ret = (ret - dp[l + 1][r - 1]) % mod;
      if (s[l] != ')' && s[r] != '(') {
        long long t = sumq[r - 1] - sumq[l];
        ret = (ret + dp[l + 1][r - 1] + p2[t]) % mod;
      }
    }
  }
  dp[0][n - 1] = (dp[0][n - 1] % mod + mod) % mod;
  cout << dp[0][n - 1] << '\n';
}
