#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long inf = 1LL << 50;
const int N = 2000;
long long dp[N][N] = {0};
long long powers[N + 5] = {0};
int sums[N + 5] = {0};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin.exceptions(cin.failbit);
  string str;
  cin >> str;
  int n = str.size();
  int last = 0;
  powers[0] = 1;
  for (int i = 0; i < n; i++) {
    dp[i][i] = 0;
    powers[i + 1] = (powers[i] * 2) % mod;
    sums[i] = last + (str[i] == '?');
    last = sums[i];
  }
  sums[n] = last;
  for (int d = 1; d < n; d++) {
    for (int l = 0; l < n - d; l++) {
      int r = l + d;
      if (str[l] != '(') {
        dp[l][r] += (dp[l][r] + dp[l + 1][r]) % mod;
      }
      if (str[r] != ')') {
        dp[l][r] = (dp[l][r] + dp[l][r - 1]) % mod;
      }
      if (str[l] != '(' && str[r] != ')') {
        dp[l][r] = (dp[l][r] - dp[l + 1][r - 1] + mod) % mod;
      }
      if (str[l] != ')' && str[r] != '(') {
        dp[l][r] =
            (dp[l][r] + dp[l + 1][r - 1] + powers[sums[r - 1] - sums[l]]) % mod;
      }
    }
  }
  cout << dp[0][n - 1] << '\n';
}
