#include <bits/stdc++.h>
using namespace std;
const int N = 2005, M = 998244353;
int C[N][N];
void pre() {
  for (int i = 0; i < N; i++) C[i][0] = 1;
  for (int i = 1; i < N; i++)
    for (int j = 1; j < N; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % M;
}
int main() {
  pre();
  string s;
  cin >> s;
  int rclose = 0, rques = 0, lopen = 0, lques = 0;
  for (char c : s)
    if (c == ')')
      rclose++;
    else if (c == '?')
      rques++;
  long long ans = 0;
  for (char c : s) {
    if (c == '(') lopen++;
    if (c == ')') rclose--;
    if (c == '?') lques++, rques--;
    int mn = max(rclose, lopen);
    for (int i = mn; i < N; i++) {
      int ways = (1LL * C[lques][i - lopen] * C[rques][i - rclose]) % M;
      ans = (ans + 1LL * i * ways) % M;
    }
  }
  cout << ans << endl;
}
