#include <bits/stdc++.h>
using namespace std;
long long int mod = 998244353;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<long long int> power_2(n + 1, 1);
  for (int i = 1; i < n + 1; i++) {
    power_2[i] = (2 * power_2[i - 1]) % mod;
  }
  vector<long long int> cnt(n + 1, 0);
  for (int i = 0; i < n; i++) {
    cnt[i + 1] = cnt[i];
    if (s[i] == '?') cnt[i + 1]++;
  }
  vector<vector<long long int> > dp(n, vector<long long int>(n, 0));
  for (int length = 2; length < n + 1; length++) {
    for (int i = 0; i < n - length + 1; i++) {
      int j = i + length - 1;
      if (s[i] != '(') dp[i][j] = (dp[i][j] + dp[i + 1][j]) % mod;
      if (s[j] != ')') dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
      if (s[i] != '(' && s[j] != ')')
        dp[i][j] = (dp[i][j] - dp[i + 1][j - 1] + mod) % mod;
      if (s[i] != ')' && s[j] != '(') {
        dp[i][j] = (dp[i][j] + dp[i + 1][j - 1]) % mod;
        dp[i][j] = (dp[i][j] + power_2[cnt[j] - cnt[i + 1]]) % mod;
      }
    }
  }
  long long int ans = dp[0][n - 1];
  while (ans < 0) ans += mod;
  cout << ans << endl;
  return 0;
}
