#include <bits/stdc++.h>
const int MAXN = 1000005;
const int P = 998244353;
int qpow(int n, int k) {
  int r = 1;
  while (k) {
    if (k & 1) r = 1ll * r * n % P;
    n = 1ll * n * n % P;
    k >>= 1;
  }
  return r;
}
char s[MAXN];
int n, fac[MAXN], ifac[MAXN];
int C(int n, int k) {
  if (k < 0 || k > n) return 0;
  return 1ll * fac[n] * ifac[k] % P * ifac[n - k] % P;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % P;
  ifac[n] = qpow(fac[n], P - 2);
  for (int i = n; i >= 1; i--) ifac[i - 1] = 1ll * ifac[i] * i % P;
  int a = 0, b = 0, c = 0, d = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == ')')
      b++;
    else if (s[i] == '?')
      d++;
  }
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == '(')
      a++;
    else if (s[i] == ')')
      b--;
    else
      c++, d--;
    ans = (ans + 1ll * c * C(c + d - 1, d - a + b - 1) +
           1ll * a * C(c + d, d - a + b)) %
          P;
  }
  printf("%d\n", ans);
  return 0;
}
