#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6 + 100;
const int mod = (int)998244353;
int n, pref[3][maxn], ans;
char second[maxn];
vector<int> g[maxn];
int first[maxn], inv[maxn];
int binpow(int a, int b) {
  if (b == 0) return 1;
  if (b % 2 == 0) {
    int d = binpow(a, b / 2);
    return d * 1ll * d % mod;
  } else {
    int d = binpow(a, b - 1);
    return d * 1ll * a % mod;
  }
}
int C(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  return (first[n] % mod * 1ll * inv[k] % mod) % mod * 1ll * inv[n - k] % mod %
         mod;
}
pair<int, int> get1(int dep) {
  int l = 1, r = n, res = -1, res2 = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (dep - pref[0][mid] >= 0) {
      res = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  if (res == -1) return make_pair(0, 0);
  l = 1, r = res;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (dep - pref[0][mid] <= pref[2][mid])
      res2 = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  if (res2 == -1) return make_pair(0, 0);
  return make_pair(res2, res);
}
pair<int, int> get2(int dep) {
  int l = 1, r = n, res = -1, res2 = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (dep - (pref[1][n] - pref[1][mid]) >= 0) {
      res = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  if (res == -1) return make_pair(mod, mod);
  l = res, r = n;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (dep - (pref[1][n] - pref[1][mid]) <= pref[2][mid])
      res2 = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  if (res2 == -1) return make_pair(mod, mod);
  return make_pair(res, res2);
}
int main() {
  first[0] = 1;
  inv[0] = 1;
  for (int i = (1); i <= (maxn - 1); ++i) {
    first[i] = first[i - 1] * 1ll * i % mod;
    inv[i] = binpow(first[i], mod - 2);
  }
  scanf("%s", second);
  n = strlen(second);
  for (int i = (1); i <= (n); ++i) {
    pref[0][i] = pref[0][i - 1] + (second[i - 1] == '(');
    pref[1][i] = pref[1][i - 1] + (second[i - 1] == ')');
    pref[2][i] = pref[2][i - 1] + (second[i - 1] == '?');
  }
  for (int j = (1); j <= (n / 2); ++j) {
    pair<int, int> seg1 = get1(j);
    pair<int, int> seg2 = get1(j);
    for (int i = (max(seg1.first, seg2.first));
         i <= (min(seg1.second, seg2.second)); ++i) {
      int way1 = C(pref[2][i], j - pref[0][i]);
      int way2 = C(pref[2][n] - pref[2][i], j - (pref[1][n] - pref[1][i]));
      ans = (ans + (way1 * 1ll * way2) % mod * 1ll * j % mod) % mod;
    }
  }
  cout << ans;
}
