#include <bits/stdc++.h>
using namespace std;
long long gi() {
  char cc = getchar();
  long long cn = 0, flus = 1;
  while (cc < '0' || cc > '9') {
    if (cc == '-') flus = -flus;
    cc = getchar();
  }
  while (cc >= '0' && cc <= '9') cn = cn * 10 + cc - '0', cc = getchar();
  return cn * flus;
}
const long long N = 1e6 + 5;
const long long P = 998244353;
char s[N];
long long cnt, n, c1[N], c2[N], pre[N], nxt[N], A[N], B[N], Ans;
long long fpow(long long x, long long k) {
  long long ans = 1, base = x;
  while (k) {
    if (k & 1) ans = ans * base % P;
    base = base * base % P, k >>= 1;
  }
  return ans % P;
}
signed main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (register long long i = 1; i <= n; ++i)
    if (s[i] == '?') ++cnt;
  c1[0] = c2[0] = 1;
  for (register long long i = 1; i <= n; ++i) {
    pre[i] = pre[i - 1];
    if (s[i] == '?') ++pre[i];
    A[i] = A[i - 1];
    if (s[i] == '(') ++A[i];
  }
  for (register long long i = n; i >= 1; --i) {
    nxt[i] = nxt[i + 1];
    if (s[i] == '?') ++nxt[i];
    B[i] = B[i + 1];
    if (s[i] == ')') ++B[i];
  }
  for (register long long i = 1; i <= cnt; ++i)
    c1[i] = c1[i - 1] * (cnt - i + 1) % P * fpow(i, P - 2) % P;
  for (register long long i = 1; i <= cnt; ++i)
    c2[i] = c2[i - 1] * (cnt - i) % P * fpow(i, P - 2) % P;
  for (register long long i = 1; i <= cnt; ++i)
    c1[i] = (c1[i] + c1[i - 1]) % P, c2[i] = (c2[i] + c2[i - 1]) % P;
  for (register long long i = 1; i <= n; ++i) {
    long long m = A[i - 1] - B[i + 1] + pre[i - 1] - 1;
    if (m < 0) continue;
    if (s[i] == ')') Ans = (Ans + c1[min(m, cnt)]) % P;
    if (s[i] == '?') Ans = (Ans + c2[min(m, cnt - 1)]) % P;
  }
  printf("%lld\n", Ans);
  return 0;
}
