#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int fac[N], ifac[N], inv[N], p[N], s[N], l[N], r[N], ans, n;
char S[N];
inline int C(const int n, const int m) {
  return n < m || m < 0
             ? 0
             : (0ll + fac[n]) * ifac[m] % 998244353 * ifac[n - m] % 998244353;
}
int main() {
  scanf("%s", S + 1), n = strlen(S + 1);
  register int i;
  for (fac[0] = fac[1] = ifac[0] = ifac[1] = inv[0] = inv[1] = 1, i = 2; i <= n;
       ++i)
    fac[i] = (0ll + fac[i - 1]) * i % 998244353,
    inv[i] =
        (0ll + inv[998244353 % i]) * (998244353 - 998244353 / i) % 998244353,
    ifac[i] = (0ll + ifac[i - 1]) * inv[i] % 998244353;
  for (i = 1; i <= n; ++i)
    l[i] = l[i - 1] + (S[i] == '('), p[i] = p[i - 1] + (S[i] == '?');
  for (i = n; i; --i)
    s[i] = s[i + 1] + (S[i] == '?'), r[i] = r[i + 1] + (S[i] == ')');
  for (i = 1; i <= n; ++i)
    ans = (ans + (0ll + l[i]) * C(p[i] + s[i + 1], s[i + 1] + r[i + 1] - l[i]) +
           (0ll + p[i]) *
               C(p[i] + s[i + 1] - 1, s[i + 1] + r[i + 1] - l[i] - 1)) %
          998244353;
  printf("%d", ans);
  return 0;
}
