#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x = 0, f = 1;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
  return x * f;
}
inline int Mul(int a, int b) { return 1ll * a * b % 998244353; }
inline int Inc(int a, int b) {
  return (a += b) >= 998244353 ? a - 998244353 : a;
}
inline int Dec(int a, int b) { return (a -= b) < 0 ? a + 998244353 : a; }
inline int qpow(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = Mul(r, a);
    a = Mul(a, a), b >>= 1;
  }
  return r;
}
int fac[1000006], inv[1000006], n, m, a[1000006], b[1000006], sum[2][1000006],
    c[1000006], d[1000006], Ans;
char s[1000006];
inline int C(int n, int m) { return Mul(Mul(fac[n], inv[n - m]), inv[m]); }
inline void solve(int opt, int x) {
  sum[opt][0] = 1;
  for (int i = (1), iLimit = (x); i <= iLimit; ++i)
    sum[opt][i] = Inc(sum[opt][i - 1], C(x, i));
}
inline int doit(int c, int x) { return (x < 0) ? 0 : min(x, d[1] - c); }
int main() {
  scanf("%s", s + 1), n = strlen(s + 1), fac[0] = 1;
  for (int i = (1), iLimit = (n); i <= iLimit; ++i) fac[i] = Mul(fac[i - 1], i);
  inv[n] = qpow(fac[n], 998244353 - 2);
  for (int i = (n - 1), iLimit = (0); i >= iLimit; --i)
    inv[i] = Mul(inv[i + 1], i + 1);
  for (int i = (1), iLimit = (n); i <= iLimit; ++i)
    a[i] = a[i - 1] + (s[i] == '('), c[i] = c[i - 1] + (s[i] == '?');
  for (int i = (n), iLimit = (1); i >= iLimit; --i)
    b[i] = b[i + 1] + (s[i] == ')'), d[i] = d[i + 1] + (s[i] == '?');
  solve(1, d[1]), solve(0, d[1] - 1);
  for (int i = (1), iLimit = (n); i <= iLimit; ++i) {
    if (s[i] == '(' && b[i] + d[i] - a[i] > -1)
      Ans = Inc(Ans, sum[1][doit(0, b[i] + d[i] - a[i])]);
    if (s[i] == '?' && b[i] + d[i] - a[i] > 1)
      Ans = Inc(Ans, sum[0][doit(1, b[i] + d[i] - a[i] - 2)]);
  }
  printf("%d", Ans);
  return 0;
}
