#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
const int mod = 998244353;
char str[MAXN];
int f[MAXN][MAXN];
int cnt[MAXN];
int qpow(int z) {
  int res = 1;
  for (int d = 2; z; z >>= 1, d = (long long)d * d % mod)
    if (z & 1) res = (long long)res * d % mod;
  return res;
}
int add(int a, int b) {
  a += b;
  return a >= mod ? (a - mod) : a;
}
int main() {
  scanf("%s", str + 1);
  int n = strlen(str + 1);
  for (int i = 1; i <= n; i++) cnt[i] = cnt[i - 1] + (str[i] == '?');
  for (int i = 1; i < n; i++)
    if (str[i] != ')' && str[i + 1] != '(') f[i][i + 1] = 1;
  for (int b = 2; b < n; b++)
    for (int l = 1, r; (r = l + b) <= n; l++) {
      if (str[l] != '(') {
        f[l][r] = add(f[l][r], f[l + 1][r]);
      }
      if (str[r] != ')') {
        f[l][r] = add(f[l][r], f[l][r - 1]);
      }
      if (str[l] != '(' && str[r] != ')') {
        f[l][r] = add(f[l][r], mod - f[l + 1][r - 1]);
      }
      if (str[l] != ')' && str[r] != '(') {
        f[l][r] = add(f[l][r], add(f[l + 1][r - 1], qpow(cnt[r - 1] - cnt[l])));
      }
    }
  printf("%d\n", f[1][n]);
  return 0;
}
