#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int fac[1000010], inv[1000010], pre[3][1000010], suf[3][1000010];
char s[1000010];
inline int C(const register int x, const register int y) {
  return x >= y && x >= 0 && y >= 0
             ? 1ll * fac[x] * inv[y] % mod * inv[x - y] % mod
             : 0;
}
int main() {
  int n;
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = fac[0] = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= n; i++)
    inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
  for (int i = 2; i <= n; i++) inv[i] = 1ll * inv[i - 1] * inv[i] % mod;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) pre[j][i] = pre[j][i - 1];
    pre[s[i] == '(' ? 0 : s[i] == ')' ? 1 : 2][i]++;
  }
  for (int i = n; i; i--) {
    for (int j = 0; j < 3; j++) suf[j][i] = suf[j][i + 1];
    suf[s[i] == '(' ? 0 : s[i] == ')' ? 1 : 2][i]++;
  }
  int ans = 0;
  for (int i = 0; i <= n; i++)
    ans =
        (ans +
         1ll * pre[0][i] * C(pre[2][n], pre[0][i] + pre[2][i] - suf[1][i + 1]) +
         1ll * pre[2][i] *
             C(pre[2][n] - 1, pre[0][i] + pre[2][i] - suf[1][i + 1])) %
        mod;
  cout << ans << endl;
}
