#include <bits/stdc++.h>
const int N = 2e6 + 233, P = 998244353;
int fac[N], ifac[N];
inline int binom(int n, int m) {
  if (n < m || n < 0 || m < 0) return 0;
  return 1ll * fac[n] * ifac[m] % P * ifac[n - m] % P;
}
inline int calc(int a, int b, int c, int d) {
  return (1ll * a * binom(b + d, b + a - c) +
          1ll * b * binom(b + d - 1, b + a - c)) %
         P;
}
char str[N];
int n, a[N], b[N], c[N], d[N], ans;
int main() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i) fac[i] = 1ll * fac[i - 1] * i % P;
  ifac[1] = ifac[0] = 1;
  for (int i = 2; i < N; ++i) ifac[i] = P - 1ll * P / i * ifac[P % i] % P;
  for (int i = 2; i < N; ++i) ifac[i] = 1ll * ifac[i - 1] * ifac[i] % P;
  scanf("%s", str + 1), n = strlen(str + 1);
  for (int i = 1; i <= n; ++i) {
    a[i] = a[i - 1] + (str[i] == '(');
    b[i] = b[i - 1] + (str[i] == '?');
  }
  for (int i = n; i; --i) {
    c[i] = c[i + 1] + (str[i] == ')');
    d[i] = d[i + 1] + (str[i] == '?');
  }
  for (int i = 1; i < n; ++i)
    ans = (ans + calc(a[i], b[i], c[i + 1], d[i + 1])) % P;
  std::cout << ans << '\n';
  return 0;
}
