#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 998244353;
long long int fpow(long long int a, long long int k) {
  long long int r = 1;
  long long int t = a;
  while (k) {
    if (k & 1) {
      r = r * t % MOD;
    }
    t = t * t % MOD;
    k >>= 1;
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<long long int>> dp(n, vector<long long int>(n));
  vector<long long int> f(n + 1);
  for (int i = 0; i < n; i++) {
    f[i + 1] = f[i];
    f[i + 1] += s[i] == '?';
  }
  for (int len = 2; len <= n; len++) {
    for (int i = 0; i < n - len + 1; i++) {
      int j = i + len - 1;
      if (s[i] != '(') {
        dp[i][j] += dp[i + 1][j];
        dp[i][j] %= MOD;
      }
      if (s[j] != ')') {
        dp[i][j] += dp[i][j - 1];
        dp[i][j] %= MOD;
      }
      if (s[i] != '(' && s[j] != ')') {
        dp[i][j] -= dp[i + 1][j - 1];
        dp[i][j] += MOD;
        dp[i][j] %= MOD;
      }
      if (s[i] != ')' && s[j] != '(') {
        dp[i][j] += dp[i + 1][j - 1];
        dp[i][j] %= MOD;
        dp[i][j] += fpow((long long int)2, (long long int)(f[j] - f[i + 1]));
        dp[i][j] %= MOD;
      }
    }
  }
  cout << dp[0][n - 1] << '\n';
  return 0;
}
