#include <bits/stdc++.h>
using namespace std;
template <typename G>
struct triple {
  G first, second, T;
  triple(G x, G y, G z) : first(x), second(y), T(z) {}
  triple() : first(0), second(0), T(0) {}
};
const long long mod = 998244353;
string s;
vector<vector<long long>> dp[2][2];
vector<int> ac;
vector<long long> pot;
long long solve(int l, int r, bool x, bool y) {
  if (r - l <= 0) return 0;
  if (dp[x][y][l][r] != -1) return dp[x][y][l][r];
  if ((!x && s[l] == ')') || (!y && s[r] == '(')) return 0;
  dp[x][y][l][r] = 0;
  if (x && (s[l] == ')' || s[l] == '?'))
    dp[x][y][l][r] = (dp[x][y][l][r] + solve(l + 1, r, true, false)) % mod;
  if (y && (s[r] == '(' || s[r] == '?'))
    dp[x][y][l][r] = (dp[x][y][l][r] + solve(l, r - 1, false, true)) % mod;
  if (x && y && (s[l] == ')' || s[l] == '?') && (s[r] == '(' || s[r] == '?'))
    dp[x][y][l][r] = (dp[x][y][l][r] + solve(l + 1, r - 1, true, true)) % mod;
  if ((s[l] == '(' || s[l] == '?') && (s[r] == ')' || s[r] == '?')) {
    long long temp = solve(l + 1, r - 1, true, true);
    dp[x][y][l][r] = (dp[x][y][l][r] + temp) % mod;
    dp[x][y][l][r] = (dp[x][y][l][r] + pot[ac[r] - ac[l + 1]]) % mod;
  }
  return dp[x][y][l][r];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  int n = s.size();
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      dp[i][j] = vector<vector<long long>>(n, vector<long long>(n, -1));
  ac = vector<int>(n + 1);
  for (int i = 1; i <= n; i++) ac[i] = ac[i - 1] + (s[i - 1] == '?');
  pot = vector<long long>(n + 1);
  pot[0] = 1;
  for (int i = 1; i <= n; i++) pot[i] = pot[i - 1] * 2 % mod;
  cout << solve(0, n - 1, true, true) << '\n';
  return 0;
}
