#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll P = 998244353LL;
string s;
int n;
vector<int> ct;
vector<vector<ll>> f;
vector<ll> pow2;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> s;
  n = s.length();
  ct.clear();
  ct.resize(n + 1);
  pow2.clear();
  pow2.resize(n + 1);
  ct[0] = 0;
  pow2[0] = 1LL;
  for (int i = 1; i <= n; i++) {
    ct[i] = ct[i - 1] + (s[i - 1] == '?' ? 1 : 0);
    pow2[i] = (pow2[i - 1] * 2) % P;
  }
  f.resize(n, vector<ll>(n));
  for (int len = 2; len <= n; len++) {
    for (int i = 0; i + len - 1 < n; i++) {
      int j = i + len - 1;
      ll &c = f[i][j];
      int ms = ct[j + 1 - 1] - ct[i + 1];
      if (s[i] == ')') c = f[i + 1][j];
      if (s[j] == '(') c = f[i][j - 1];
      if (s[i] == '(' && s[j] == ')') c = (f[i + 1][j - 1] + pow2[ms]) % P;
      if (s[i] == '(' && s[j] == '?')
        c = (f[i][j - 1] + f[i + 1][j - 1] + pow2[ms]) % P;
      if (s[i] == '?' && s[j] == ')')
        c = (f[i + 1][j - 1] + pow2[ms] + f[i + 1][j]) % P;
      if (s[i] == '?' && s[j] == '?') {
        c = (f[i + 1][j] + f[i][j - 1] + pow2[ms]) % P;
      }
    }
  }
  cout << f[0][n - 1] << endl;
  return 0;
}
