#include <bits/stdc++.h>
using i64 = long long;
constexpr int P = 998244353;
int power(int a, int b) {
  int res = 1;
  for (; b > 0; a = i64(a) * a % P, b /= 2) {
    if (b % 2 == 1) {
      res = i64(res) * a % P;
    }
  }
  return res;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::string s;
  std::cin >> s;
  int n = s.size();
  std::vector<int> pr(n + 1);
  for (int i = 0; i < n; i++) {
    pr[i + 1] = pr[i] + (s[i] == '?');
  }
  std::vector<std::vector<int>> dp(n, std::vector<int>(n, -1));
  std::function<int(int, int)> calc = [&](int l, int r) {
    if (l >= r) {
      return 0;
    }
    if (~dp[l][r]) {
      return dp[l][r];
    }
    dp[l][r] = 0;
    if (s[l] != '(') dp[l][r] = (dp[l][r] + calc(l + 1, r)) % P;
    if (s[r] != ')') dp[l][r] = (dp[l][r] + calc(l, r - 1)) % P;
    if (s[l] != '(' && s[r] != ')')
      dp[l][r] = (dp[l][r] - calc(l + 1, r - 1) + P) % P;
    if (s[l] != ')' && s[r] != '(')
      dp[l][r] =
          ((dp[l][r] + calc(l + 1, r - 1)) % P + power(2, pr[r] - pr[l + 1])) %
          P;
    return dp[l][r];
  };
  std::cout << calc(0, n - 1) << "\n";
  return 0;
}
