#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
const int mods[10] = {1000000007, 999999937, 999999929, 999999893, 999999883,
                      999999797,  999999761, 999999757, 999999751, 999999739};
const int mod = 998244353;
int rand_mods[2];
const long double eps = 1e-10;
const int siz = 2e3 + 5, siz2 = 3e5 + 5, lg = 20, block = 300, block2 = 1000,
          mxv = 1e5 + 1, sqrt_mod = 31630;
const int alpha_sz = 26;
char arr[siz];
int dp[siz][siz], qcmu[siz];
int mul(long long a, long long b) { return (a * b) % mod; }
int sub(long long a, long long b) { return ((a - b) % mod + mod) % mod; }
int powmod(int a, int b) {
  if (b == 0) {
    return 1;
  }
  int p = powmod(a, b / 2);
  p = mul(p, p);
  return b % 2 ? mul(p, a) : p;
}
int add(long long a, long long b) { return (a + b) % mod; }
int main() {
  scanf("%s", arr + 1);
  int sz = strlen(arr + 1);
  for (int i = 1; i <= sz; i++) {
    qcmu[i] = (arr[i] == '?') + qcmu[i - 1];
  }
  for (int i = 1; i < sz; i++) {
    dp[i][i + 1] = arr[i] != ')' && arr[i + 1] != '(';
  }
  for (int len = 3; len <= sz; len++) {
    for (int i = 1; i + len - 1 <= sz; i++) {
      int l = i, r = i + len - 1;
      if (arr[l] != ')' && arr[r] != '(') {
        dp[l][r] = add(dp[l + 1][r - 1], powmod(2, qcmu[r - 1] - qcmu[l]));
      }
      if (arr[l] != '(') {
        dp[l][r] = add(dp[l][r], dp[l + 1][r]);
      }
      if (arr[r] != ')') {
        dp[l][r] = add(dp[l][r], dp[l][r - 1]);
      }
      if (arr[l] != '(' && arr[r] != ')') {
        dp[l][r] = sub(dp[l][r], dp[l + 1][r - 1]);
      }
    }
  }
  printf("%d\n", dp[1][sz]);
  return 0;
}
