#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010, P = 998244353;
int n, fact[maxn], inv[maxn], finv[maxn], suf[2][maxn];
char s[maxn];
int qp(int x, int y) {
  int z = 1;
  for (; y; y >>= 1, x = 1LL * x * x % P) {
    if (y & 1) z = 1LL * z * x % P;
  }
  return z;
}
int C(int x, int y) { return 1LL * fact[x] * finv[y] % P * finv[x - y] % P; }
int main() {
  scanf("%s", s + 1), n = strlen(s + 1);
  fact[0] = inv[0] = inv[1] = finv[0] = 1;
  int cnt = 0, tmp = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == ')') tmp++;
    if (s[i] == '?') cnt++;
    fact[i] = 1LL * i * fact[i - 1] % P;
    if (i > 1) inv[i] = 1LL * (P - P / i) * inv[P % i] % P;
    finv[i] = 1LL * finv[i - 1] * inv[i] % P;
  }
  for (int i = 0; i < 2; i++) {
    for (int j = cnt - i; ~j; j--) {
      suf[i][j] = (suf[i][j + 1] + C(cnt - i, j)) % P;
    }
  }
  int ans = 0;
  for (int i = 1, a = 0, b = 0, c = 0; i <= n; i++) {
    if (s[i] == '(') a++;
    if (s[i] == ')') b++;
    if (s[i] == '?') c++;
    int t = a - (tmp - b) + c;
    if (s[i] == '(') (ans += suf[0][max(0, t)]) %= P;
    if (s[i] == '?') (ans += suf[1][max(0, t)]) %= P;
  }
  printf("%d\n", ans);
  return 0;
}
