#include <bits/stdc++.h>
long long fac[2222222], inv[2222222];
const long long mod = 119 << 23 | 1;
long long qpow(long long x, long long k) {
  long long r = 1;
  for (; k; k >>= 1, (x *= x) %= mod)
    if (k & 1) (r *= x) %= mod;
  return r;
}
void precalc() {
  register int i;
  const int lm = 2e6;
  for (i = fac[0] = 1; i <= lm; i++) fac[i] = fac[i - 1] * i % mod;
  for (i = lm, inv[i] = qpow(fac[i], mod - 2); i; i--)
    inv[i - 1] = inv[i] * i % mod;
}
long long C(long long n, long long r) {
  return (n < r || r < 0) ? 0 : fac[n] * inv[r] % mod * inv[n - r] % mod;
}
long long solve(long long l, long long r, long long x, long long y) {
  return (l * C(x + y, y - l + r) + x * C(x + y - 1, y - l + r - 1)) % mod;
}
long long L[1111111], R[1111111], X[1111111], Y[1111111];
char str[1111111];
int main() {
  precalc();
  scanf("%s", str + 1);
  int n = strlen(str + 1);
  register int i;
  for (i = 1; i <= n; i++)
    L[i] = L[i - 1] + (str[i] == '('), X[i] = X[i - 1] + (str[i] == '?');
  for (i = n; i; i--)
    R[i] = R[i + 1] + (str[i] == ')'), Y[i] = Y[i + 1] + (str[i] == '?');
  long long ans = 0;
  for (i = 1; i < n; i++) ans += solve(L[i], R[i + 1], X[i], Y[i + 1]);
  printf("%lld\n", ans % mod);
}
