#include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 5;
const int MOD = 998244353;
char s[N];
long long f[N][N];
long long pow2[N];
int cnt[N];
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  for (int i = 1; i <= n; i++) cnt[i] = cnt[i - 1] + (s[i] == '?');
  pow2[0] = 1;
  for (int i = 1; i < N; i++) pow2[i] = 2LL * pow2[i - 1] % MOD;
  for (int l = 2; l <= n; l++)
    for (int i = 1; i + l - 1 <= n; i++) {
      int j = i + l - 1;
      if (s[i] != '(') f[i][j] = (f[i][j] + f[i + 1][j]) % MOD;
      if (s[j] != ')') f[i][j] = (f[i][j] + f[i][j - 1]) % MOD;
      if (s[i] != '(' && s[j] != ')')
        f[i][j] = (f[i][j] - f[i + 1][j - 1]) % MOD;
      if (s[i] != ')' && s[j] != '(') {
        int m = cnt[j - 1] - cnt[i];
        f[i][j] = (f[i][j] + f[i + 1][j - 1] + pow2[m]) % MOD;
      }
    }
  cout << (f[1][n] + MOD) % MOD;
  return 0;
}
